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
Post a Comment