Vì vậy, tôi đã bắt đầu tạo một số xét nghiệm đơn vị Ruby sử dụng Selenium RC để kiểm tra ứng dụng web của tôi trực tiếp trong trình duyệt. Tôi đang sử dụng số Selenum-Client cho ruby. Tôi đã tạo một lớp cơ sở cho tất cả các bài kiểm tra selen khác của tôi để kế thừa từ đó.Selenium RC: Chạy thử nghiệm trong nhiều trình duyệt tự động
Điều này tạo ra nhiều trường hợp SeleniumDriver và tất cả các phương thức bị thiếu được gọi trên mỗi trường hợp. Điều này về cơ bản chạy các bài kiểm tra song song.
Làm cách nào để những người khác tự động hóa điều này?
Đây là triển khai thực hiện của tôi:
class SeleniumTest < Test::Unit::TestCase
def setup
@seleniums = %w(*firefox *iexplore).map do |browser|
puts 'creating browser ' + browser
Selenium::SeleniumDriver.new("localhost", 4444, browser, "http://localhost:3003", 10000)
end
start
open start_address
end
def teardown
stop
end
#sub-classes should override this if they want to change it
def start_address
"http://localhost:3003/"
end
# Overrides standard "open" method
def open(addr)
method_missing 'open', addr
end
# Overrides standard "type" method
def type(inputLocator, value)
method_missing 'type', inputLocator, value
end
# Overrides standard "select" method
def select(inputLocator, optionLocator)
method_missing 'select', inputLocator, optionLocator
end
def method_missing(method_name, *args)
@seleniums.each do |selenium_driver|
if args.empty?
selenium_driver.send method_name
else
selenium_driver.send method_name, *args
end
end
end
end
này hoạt động, nhưng nếu một trình duyệt không thành công, toàn bộ thử nghiệm thất bại và không có cách nào để biết được trình duyệt nó không thành công trên.
Xin chào Daniel, tôi có một câu hỏi tương tự. Tôi đã tự hỏi nếu bạn có thể giúp đỡ. [Selenium RC: Cách khởi chạy Thử nghiệm tương tác với nhiều trình duyệt] (http://stackoverflow.com/questions/2836313/selenium-rchow-to-launch-interactive-testing-with-multiple-browsers) – onesith