In that case Watir locates potentially matching elements and iterates over them to provide the requested result. While I have seen some mentions that css locators are faster, I have not seen a practical or significant difference. By continuing to use this website, you agree to their use. Notify me of new comments via email. The locator is simply passed on as written. Create a free website or blog at WordPress.

Uploader: Nikorr
Date Added: 2 October 2018
File Size: 51.3 Mb
Operating Systems: Windows NT/2000/XP/2003/2003/7/8/10 MacOS 10/X
Downloads: 5004
Price: Free* [*Free Regsitration Required]

Finding Watir Elements with XPATH

When using Watir-Webdriver, using XPath does not have a negative performance impact. The Answer The Xpath of an element is essentially a direct, precise roadmap to the specific element you are trying to select for your automated test. When using Watir-Classic, avoid using XPath.

Accept String values for exact matching Accept RegExp values for partial matching Can be mixed with any other Watir Locator Can be used to find the first watri element, or all matching elements as part of a collection Wedriver, like Selenium, Watir supports the full power of directly using: Solution — XPath XPath is similar to css locators.

This entry was posted in WatirWatir-ClassicWatir-Webdriver and tagged custom attributelocatorwatirwatir-webdriver. Post as a guest Name. With Watir you can locate any element by its text, not just links, and Watir already supports partial matches xpah all of its locators with Regular Expressions. The test page was a simple table: This will your automation script writing process become more efficient by xpxth time wasted searching for a working element identifier.


One of the most important features of Watir is the many varied ways it allows users to locate elements. We are working on improving the time it takes to select the wxtir. You can get a sense for what this looks like by checking out our sample app XPathify.

Here is the code we received from our Xpath in the previous section:.

Locating Elements – Watir Project

This site uses cookies. Fill in your details below or click an icon to log in: Now that we have our Xpath, we can put it into a Watir-Webdriver command, which will look like this:.

Benchmarking the most common locator —: The special cases will be highlighted below, but Watir Locators: The locator is simply passed on as written. By continuing to use this website, you agree to their use.

Email required Address never made public. As the performance concern started debdriver long time ago, it makes sense to investigate Watir-Classic first. We can obtain our Xpath by inspecting the element we want. As long as the browser element exists, you can obtain the Xpath for interactions with Ruby, Selenium, and Watir Webdriver.


While you can attempt to use index as discussed in a previous How To postthere is another option available: If you are looking to get the best performance: Stack Overflow works best with JavaScript enabled.

You hlw commenting using your WordPress.

You are commenting using your Twitter account. For simplicity, we will ignore the special handling for Regexp values. Elements are located by creating a Selector Hash, which Watir translates into the potentially complicated information the driver uwe to know to identify the element.

Sign up using Facebook. Therefore, you would have to locate it as an element and then convert it to its subtype. I have some HTML that looks like this: