Note that there are some explanatory texts on larger screens.

plurals
  1. POTrouble with Selenium Client for Ruby and Xpath Selectors - multiple links from a single table
    primarykey
    data
    text
    <p>I'm porting over a few scripts from Watir to Selenium-RC to see how difficult the change may be for our organization.</p> <p>I have a table with class 'global-list', that contains 4 columns, each column with an unordered list, and each list element containing a word with a hyperlink.</p> <p>In Watir, I would simply use: </p> <blockquote> <p><code>@browser.table(:class, /global-list/).links.each {|link| puts link.text,link.href}</code></p> </blockquote> <p>With Selenium there doesn't appear to be such an easy way to do this. I want all of the links (href and text) from that single table. At first I thought my Xpath was incorrect because it would only show me the first column (of 4), or the first href element.</p> <blockquote> <p><code>puts @browser.get_xpath_count("//table[@class='global-list']//a[@href]")</code><br> - gives me a result of 64 links (the total across all 4 tr's and/or ul's).</p> <p><code>puts @browser.get_text("//table[@class='global-list']//a[@href]")</code><br> - gives me a single text result (just the first td in the first tr).</p> <p><code>puts @browser.get_text("//ul[@class='global-list']")</code><br> - gives me the first column of text only (the first ul in the first tr).</p> </blockquote> <p>I am new to Selenium, but I have read the documentation and available methods (<a href="http://selenium-client.rubyforge.org/" rel="nofollow">http://selenium-client.rubyforge.org/</a>) and do not yet see a straightforward solution.</p> <p>I have also tried the DOM locator method, but if get_text or get_attribute are my only options, I'm not able to improve my results that way.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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