Most of the time Watir can translate the Selector Hash into a single XPath expression to quickly identify the element. This post will describe briefly how to use basic css and xpath locators. When either of these are used, they must be the only one provided in the Selector Hash. By clicking “Post Your Answer”, you acknowledge that you have read our updated terms of service , privacy policy and cookie policy , and that your continued use of the website is subject to these policies. This site uses cookies. One of the reasons being the poor performance when locating elements.

Uploader: Kimuro
Date Added: 13 November 2018
File Size: 11.98 Mb
Operating Systems: Windows NT/2000/XP/2003/2003/7/8/10 MacOS 10/X
Downloads: 61498
Price: Free* [*Free Regsitration Required]

The highlighted element we will be taking the Xpath from. One of the most important features of Watir is the many varied ways it allows users to locate elements. Now that we know how to obtain Xpath and put it into a Watir Webdriver Command, lets create a sample automation script utilizing Xpath. 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.

As an example, assume that the following HTML exists on the page. There are many different ways to do this.


XPath is similar to css locators. Firstly, like Selenium, Watir supports the full power of directly using: We see that each additional element method call has a significant impact, while the XPath performance is not impacted:.

How To Utilize Xpath With Selenium & Watir Webdriver to Find Browser Elements

You can get a sense for what this looks like by checking out our sample app XPathify. The Wfbdriver location API is designed to be easily read and understood by users humans. By continuing to use this website, you agree to their use. When either of these are used, they must be the only one provided in the Selector Hash. Using Xpath will allow to have a direct way to pinpoint your desired element and utilize it in a Watir-Webdriver command.

Solution — XPath XPath is similar to css locators.

How to access element using Watir and XPath – Stack Overflow

This entry was posted in WatirWatir-ClassicWatir-Webdriver and tagged locatorperformancexpath. The locator is simply passed on as written. You are commenting using your Twitter account. This site uses cookies.

The following benchmark located the table by webdrive id times: For simplicity, we will ignore the special handling for Regexp values. Posted by 3QI Labs.


We are working on improving the time it takes to select the element. This post will describe briefly how to use basic css and xpath locators. This will your automation script writing process become more efficient by eliminating time wasted searching for watid working element identifier. Create a free website or blog at WordPress. When using Watir-Webdriver, using XPath does not have a negative performance impact.

As the performance concern started a long time ago, it makes sense to investigate Watir-Classic first. Some comments I have seen over time include: Checkout this simple framework that I uploaded to Github: Occasionally I still see warnings of poor performance, but there seems to be more uncertainty. In some cases, XPath actually improves performance. The watri cases will be highlighted below, but Watir Locators: Notify me of new comments via email.

Leave a Reply Cancel reply Enter your comment here Notify me of new comments via email. Problem In the past, the Watir community has been resistive to using XPath locators.