我必须在 IE 10 浏览器上运行 Selenium 测试。为了运行以下脚本,我执行了以下操作:
- 从这里下载 IEDriverServer(64 位,因为我的机器是 64 位)
- 将该(.exe)文件放在“C://驱动程序”文件夹中
- 在环境变量中设置路径“C://drivers”
运行脚本
require 'selenium-webdriver' driver = Selenium::WebDriver.for :ie driver.get "http://www.google.com" button = driver.find_element(:id, "gbqfba") puts button.text driver.quit
运行 aboe 脚本会导致以下错误:
c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/response.rb:51:in `assert_ok': Unable to find element with id == gbq
fba (Selenium::WebDriver::Error::NoSuchElementError)
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/response.rb:15:in `initialize'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/http/common.rb:59:in `new'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/http/common.rb:59:in `create_response'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/http/default.rb:66:in `request'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/http/common.rb:40:in `call'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/bridge.rb:629:in `raw_execute'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/bridge.rb:607:in `execute'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/bridge.rb:575:in `find_element_by'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/common/search_context.rb:42:in `find_element'
from ie.rb:7:in `<main>'
相同的脚本在 Chrome 和 Firefox 浏览器上运行良好。请帮助我了解我在哪里做错了。