-
Notifications
You must be signed in to change notification settings - Fork 2
No. We try to be as compatible as possible, but some changes are intentional (and documented in the watir2 branch of watirspec).
Here’s a list of the major differences.
If you believe something should be supported that is currently not, you should:
- Check that it’s not mentioned on the comparison page
- Check that there is not an existing issue opened for the problem.
- Open a new issue in the tracker.
WebDriver strives to give you the same text representation of an element across browsers (with varying degree of success), and the code to fetch the visible text of a DOM element is implemented in JS.
This works great for single elements, but can be slow when fetching the full visible text of a big page.
Among Watir users, the following idiom is common:
error_checker = lambda { raise "oops" if browser.text =~ /common error messages/ }
browser.add_checker(error_checker)Doing this can lead to a significant increase in runtime for a big test suite. It’s better to check specific elements when possible:
lambda {
element = browser.div(:id => "errors")
raise "oops" if element.exists? && element.text =~ /common error messages/
}
browser.add_checker(error_checker)If this isn’t possible, and the overhead of using Browser#text is too big, we have an optional require that will use Nokogiri to extract the text.
require "watir-webdriver/extensions/nokogiri"Note that the text returned is not limited to visible elements and that the results may vary from browser to browser.
watir-webdriver is built on top of the selenium-webdriver gem. The Selenium wiki provides details on how to configure the underlying driver. You can create a new Watir::Browser by passing in the driver instance, i.e.:
driver = Selenium::WebDriver.for :firefox
browser = Watir::Browser.new(driver)