Found elements can't be found (Ruby)

29 views
Skip to first unread message

enfrique

unread,
Feb 26, 2014, 12:29:23 PM2/26/14
to seleniu...@googlegroups.com
So I'm using this code:

@links = []
       
       @links << @driver.find_elements(:tag_name => "a")
       
       puts @links


and it returns values like this:

#<Selenium::WebDriver::Element:0x0000010225ec18>
#<Selenium::WebDriver::Element:0x0000010225eb28>
#<Selenium::WebDriver::Element:0x0000010225ea88>
#<Selenium::WebDriver::Element:0x0000010225e998>
#<Selenium::WebDriver::Element:0x0000010225e920>
#<Selenium::WebDriver::Element:0x0000010225e858>
#<Selenium::WebDriver::Element:0x0000010225e7b8>
#<Selenium::WebDriver::Element:0x0000010225e6a0>
#<Selenium::WebDriver::Element:0x0000010225e5d8>

So when the script continues and runs this:

@links.each do |link|
      value = @driver.find_element(:link => link) 
      puts value


I get results like this:

Error: test_cec_top_nav(CecTopNav)
  Selenium::WebDriver::Error::NoSuchElementError: Unable to locate element: {"method":"link text","selector":"[#<Selenium::WebDriver::Element:0x..fc06799e5bd009338 id=\"{37c39184-4a46-6940-a3d5-d866310145c7}\">



I was expecting/hoping to get plain-text hrefs that I could refer back to in the remainder of the script, and getting the hex values is fine, but it looks like webDriver can't read it's own handwriting.

What am I missing here?

Oscar Rieken

unread,
Feb 26, 2014, 10:39:44 PM2/26/14
to seleniu...@googlegroups.com
I would suggest you spend some time learning ruby. 
your error states that you are trying to locate an element using link text and the value you are passing it is a webdriver element...
another thing you are doing is putting a collection inside of an array. 


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/a27974d9-d8ea-44ea-ba37-93cc564ffc87%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages