尝试在页面中搜索正则表达式时遇到错误。我使用以下内容来实际定位正则表达式,但我收到了各种错误。
...
browser.script.html.include? "event49"
这些错误似乎与浏览器(可能还有环境)有关。我在 Safari、Chrome 和 Firefox 之间来回测试过。Firefox 似乎有间歇性问题。铬,几乎不变。我还在我的 PC 和 Mac 之间进行了测试,它似乎是全面的标准。
我对 Safari 没有任何问题。
此错误来自 Firefox:
[remote server] resource://fxdriver/modules/web_element_cache.js:7204:in `fxdriver.cache.getElementAt': Element not found in the cache - perhaps the page has changed since it was looked up (Selenium::WebDriver::Error::StaleElementReferenceError)
此错误来自 Chrome:
/Library/Ruby/Gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/remote/response.rb:52:in `assert_ok': getElementTagName execution failed; (Selenium::WebDriver::Error::StaleElementReferenceError)
Element does not exist in cache
任何帮助深表感谢!
更新:
请看下面的脚本:
require "rubygems"
require "watir-webdriver"
require "watir-webdriver-performance"
require "rspec"
include Watir
require 'logger'
browser = Watir::Browser.new :chrome
test_site = 'http://laughlin:driveafirestone@fcac-rebrand.laughlin.com/'
browser.goto(test_site)
year_select = browser.select_list(:id => 'universal-year')
browser.select_list(:id => 'universal-year', :disabled => 'disabled').wait_while_present
year_select.select '2010'
make_select = browser.select_list(:id => 'universal-make')
browser.select_list(:id => 'universal-make', :disabled => 'disabled').wait_while_present
make_select.select 'Volkswagen'
model_select = browser.select_list(:id => 'universal-model')
browser.select_list(:id => 'universal-model', :disabled => 'disabled').wait_while_present
model_select.select 'Jetta'
submodel_select = browser.select_list(:id => 'universal-submodel')
browser.select_list(:id => 'universal-submodel', :disabled => 'disabled').wait_while_present
submodel_select.select '2.0T TDI Sedan'
zipcode_input = browser.text_field(:id => 'universal-selectorZip')
zipcode_input.set '53202'
browser.button(:id => 'universal-submit-tires-quote').click
browser.script.html.include? "event49"
browser.close