我所有的自动化都在 watir-webdriver 中。我曾经将我的浏览器配置为 Firefox,如下所示:
@profile = Selenium::WebDriver::Firefox::Profile.new
@profile.native_events = false
@client = Selenium::WebDriver::Remote::Http::Default.new
@client.timeout = 300
@b = Watir::Browser.new :firefox, :profile=>@profile, :http_client=>@client
@b.driver.manage.timeouts.implicit_wait = 30
当我切换到这个时:
@server = Selenium::Server.new("./selenium-server-standalone-2.20.0.jar", :background=>true)
@server.start
@caps = Selenium::WebDriver::Remote::Capabilities.htmlunit(:javascript_enabled=>true)
@client = Selenium::WebDriver::Remote::Http::Default.new
@client.timeout = 300
@b = Watir::Browser.new(:remote, :url=>"http://127.0.0.1:4444/wd/hub", :desired_capabilities=>@caps, :http_client=>@client)
@b.driver.manage.timeouts.implicit_wait = 30
我开始在第一个非常简单的任务上失败
@b.link(:text, "Login Again").click
Watir::Exception::UnknownObjectException: unable to locate element, using {:text=>"Login Again", :tag_name=>"a"}
我怎样才能弄清楚为什么会这样以及我能做些什么呢?我不知道从哪里开始。