ruby - Can't get a element by id with selenium webdriver -


i have code this.

require "selenium-webdriver" d = selenium::webdriver.for :firefox d.navigate.to "http://finance.yahoo.com/stock-center/"  d.find_element(:id, "yfs_184_^oex") 

but code fails nosuchelementerror.

selenium::webdriver::error::nosuchelementerror: unable locate element: {"method":"id","selector":"yfs_184_^gsptse"} 

i checked existence of yfs_184_^oex element inspector.

why can't find element id?

i assume trying find element:

<span class="l84" id="yfs_l84_^oex">825.68</span> 

the problem locator there typo in id. "l84" - notice letter "l" not number "1" (as in attempted code).

d.find_element(:id, "yfs_l84_^oex") 

with change, script work:

require "selenium-webdriver"  d = selenium::webdriver.for :firefox d.navigate.to "http://finance.yahoo.com/stock-center/"  e = d.find_element(:id, "yfs_l84_^oex") e.text #=> "825.68" 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -