Category Archives: Watir-Classic

Replace Table#row_count and Table#column_count with an ElementCollection#count

Given a table: You might want to check the number of rows and/or columns. Obsolete Method In Watir-Classic you may have retrieved these values using the row_count and column_count methods. However, these methods will give an error in Watir-Webdriver: Preferred … Continue reading

Posted in Watir, Watir Migration, Watir-Classic | Leave a comment

Watir 6.0 is the end of the Watir metagem

The Watir gem started out as driver for IE through the OLE protocol. In 2012, version 4.0.0 changed Watir into a metagem that, based on the desired browser, used either Watir-Classic (the original implementation) or Watir-Webdriver (the Selenium backed implementation … Continue reading

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

Toggle a checkbox

Problem Checking a checkbox is as simple as: Clearing a checkbox is just as easy: What if you want to toggle the state of the checkbox – ie check it if its unchecked or uncheck it if it is checked? … Continue reading

Posted in Watir, Watir-Classic, Watir-Webdriver | Tagged | 16 Comments

Translating a headers attribute to text

Problem I was struggling to determine a cell’s headers associated via the headers attribute. The table was large with auto-generated ids, which created headers attributes like: Finding each of the header cells became tedious, so I turned to Watir for … Continue reading

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

Returning Watir element from execute_script

Question I noticed the following Stack Overflow answer by Jeff Price yesterday: One thing we have done at times when a query becomes oppressive is to get out of the selenium/watir loop altogether and ask the browser to execute some … Continue reading

Posted in Watir, Watir-Classic, 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

Check if an element is within another element

Problem Consider the following HTML where the span is the child element of interest: Given we have created a reference to each of the elements: How do you check which include the child element? Solution The Element#== method allows you … Continue reading

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