我正在使用Selenium-webdriver运行黄瓜测试。 当我运行功能时,测试失败并显示
Selenium :: WebDriver :: Error :: UnknownError:未知错误:attribute_value.lastIndexOf不是函数
[5] pry(#<Object>)> fill_in 'q', with: company_id
=> #<Capybara::Node::Element tag="input"
path="/html/body/div/div[3]/div/div/div[1]/form/div/input[1]">
[6] pry(#<Object>)> click_on 'Search'
Selenium::WebDriver::Error::UnknownError: unknown error:
attribute_value.lastIndexOf is not a function
(Session info: chrome=70.0.3538.110)
(Driver info: chromedriver=2.36.540469
(1881fd7f8641508feb5166b7cae561d87723cfa8),platform=Mac OS X 10.14.0 x86_64)
from /Users/Sergei/.rvm/gems/ruby-2.3.1@web-autotest/gems/selenium-webdriver-
3.0.8/lib/selenium/webdriver/remote/response.rb:69:in `assert_ok'
def self.assert_html
# Search whole document instead of current_scope
time = Benchmark.realtime do
document = Capybara.page.document
expect(document).not_to have_css('.pages500')
log_entries = Capybara.page.driver.browser.manage.logs.get(:browser)
log_entries.reject! { |e| %w(INFO WARNING).include? e.level }
$world.puts "Browser log entries: #{log_entries.map(&:to_s)}" unless log_entries.empty?
if Capybara.current_url.start_with? 'https'
js = "tags_attrs = ["\
" ['script, source, audio, iframe', 'src'],"\
" ['object', 'data'],"\
" ['link', 'href'],"\
" ['form', 'action'],"\
" ['video', 'data-stream']"\
"];"\
"incorrect_urls = [];"\
"for (i=0; i<tags_attrs.length; i++) {"\
" tags_attr = tags_attrs[i];"\
" elements = document.getElementsByTagName(tags_attr[0]);"\
" for (j=0; j<elements.length; j++) {"\
" element = elements[j];"\
" attribute_value = element[tags_attr[1]];"\
" if (attribute_value) {"\
" if (attribute_value.lastIndexOf('http://', 0) === 0) {"\
" incorrect_urls.push(attribute_value)"\
" }"\
" }"\
" }"\
"}"\
"return incorrect_urls;"
incorrect_urls = page.execute_script(js)
expect(incorrect_urls).to be_empty
end
end
end
Chrome版本:70.0.3538.110版(官方内部版本)(64位) 也许有人对如何解决有任何想法?
答案 0 :(得分:0)
您使用的chromedriver
和selenium-webdriver
的版本已经过时,并且与您使用的Chrome版本不兼容-请对其进行更新。