Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>generally the .exists? method is your best bet to see if a given element exists. it returns true or false.. </p> <p>browser.cell(:id, 'attr-translation-col').exists?</p> <p>=-=-=-= Edit to reflect stuff learned via comments and some resulting investigation =-=-=-=</p> <p>the .cell method is implemented very differently in Watir vs Watir-Webdriver. This does not appear to be included in the doc about the differences between the two.</p> <p>In Watir, the <em>.cell</em> method is defined in the <em>Watir::Container</em> module and returns a <em>tablecell</em> object. This makes the <em>.cell</em> method available nearly anywhere from anything that inherets from <em>Container</em> or includes it. For example the <em>IE</em> object. The <em>tablecell</em> object is inhereted from the <em>Element</em> class, and thus has access to most of the expected methods such as <em>.exists?</em></p> <p>In Watir-Webdriver, the <em>.cell</em> method is defined in <em>Watir::CellContainer</em>. That module is included in <em>Watir::TableRow</em>, which means that (presuming I am understanding this correctly) the <em>.cell</em> method is only available from within a TableRow object, or something that includes <em>TableRow</em> or inherits from it. For example if you review a Watir-Webdriver <em>Browser</em> object, you won't see the <em>.cell</em> method listed. Like Watir, the <em>tablecell</em> object is inhereted from the <em>Element</em> class, and likewise should have access to the <em>.exists?</em> method.</p> <p>In contrast to <em>.cell</em>, the Watir-Webdriver methods for <em>.tr, .td, .th</em> are all defined in <em>Watir::Container</em> (as opposed to CellContainer) and thus are highly available and will usually work. </p> <p>So what this analysis of the Rdoc's for the two projects is telling me is that if you can actually get your hands on a tablecell object in Watir-webdriver, you should be able to call the .exists? method, however you might find the number of places you can use .cell to get a tablecell highly restricted since few objects support this method. If you are seeing an error about a method not existing, it may well be the .cell method, NOT the .exists? method (where Watir-Webdriver is concerned) </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload