Tag Archives: locator

The many code paths of the :id locator

Problem While investigating the changes needed for Pull Request #662, I noticed that the :id locator had quite a few code paths. For example, the locator could be: Directly passed on to Selenium-WebDriver Incorporated into an XPath expression Compared while … Continue reading

Posted in Watir | Tagged , , , | Leave a comment

Locate by classes in a specific order

Problem In HTML, the class attribute is a space-separated list of classes for the element. The order of classes does not matter when applying style sheets. For example, in the following page, all 3 div elements would look the same … Continue reading

Posted in Watir | Tagged , | Leave a comment

Finding visible/hidden elements with the new :visible locator

Watir 6.0 introduces a new locator – :visible. This allows you to specify whether or not the element can be seen by the user. Usage Consider the following page where the first div is visible and first span element is … Continue reading

Posted in Watir | Tagged , | 7 Comments

Finding the next empty text field

Problem As I continued to investigate making Watir-Classic tests compatible with Watir-Webdriver, I noticed one test that failed to input the next empty row of a text field grid. The grid could start empty or it could start with rows … Continue reading

Posted in Watir, Watir Migration, Watir-Webdriver | Tagged , , | Leave a comment

Are :xpath locators slower?

Problem In the past, the Watir community has been resistive to using XPath locators. One of the reasons being the poor performance when locating elements. Occasionally I still see warnings of poor performance, but there seems to be more uncertainty. … Continue reading

Posted in Watir, Watir-Classic, Watir-Webdriver | Tagged , , | Leave a comment

Find elements based on the presence or absence of an attribute

Watir-Webdriver Issue #345 is a feature request to locate elements based on the presence of an attribute. For example, in the following HTML, the first div element does not have the data-test attribute. The other three divs do have the … Continue reading

Posted in Watir | Tagged , , | Leave a comment

Adding custom attributes to the list of valid locators

In a previous post, I discussed how to extend Watir-Webdriver to allow locators for custom attributes. The solution involved monkey-patching the normalize_selector method, which is not ideal. However, I since learned (from Jarib in Watir-Webdriver Issue 260) that there is … Continue reading

Posted in Watir, Watir-Webdriver | Tagged , , | 2 Comments