Tag: selenium chromedriver

Watir脚本偶尔会返回Net :: ReadTimeout错误

我有一个Watir脚本,偶尔和不可预测地返回此错误: Net::ReadTimeout 我搜索了这个错误,发现这个问题已经问过。 我按照最佳答案,实施了这个: attempts = 0 url = “https:/www.google.com/” begin doc = Watir::Browser.start url rescue Net::ReadTimeout retry end 但我仍然得到相同的超时错误。 我的网络从未遇到任何连接问题。 我在Ubuntu和Windows 10机器上都出错了。 在此错误表现出来之前,我的代码平均经历了大约30次迭代。 我正在使用Chrome。 有什么建议?

Rails:Watir中的代理身份validation(Chrome驱动程序)

我试图在chrome webdriver中添加代理身份validation,它在下面的watir上运行: require ‘watir’ proxies = [‘–proxy-server=185.264.167.184:63109’, ‘–proxy-auth=username:password’] browser = Watir::Browser.new :chrome, :switches => proxies browser.goto(url) 当浏览器运行它仍然问我如下的用户名和密码: 问题是如何在watir上运行的chrome驱动程序中设置用户名和密码?

如何在测试套件中进行下一次测试之前关闭所有窗口?

[7] pry(#)> page.execute_script “window.close()” Selenium::WebDriver::Error::NoSuchWindowError: Script execution failed. Script: window.close(); The window could not be found [8] pry(#)> page.driver.browser.window_handles => [“f1-2”] 我打开了一个带有两个选项卡的浏览器,上面的命令关闭了一个,但最后一个选项卡从未关闭。 它是开放的,但是当我尝试运行page.execute_script “window.close()”它会给出上述错误。 page.driver.browser.window_handles.each do |handle| page.driver.browser.switch_to.window(handle) page.execute_script “window.close()” end 上面的代码在某个时候对我有用,但不再起作用了。 它给出了同样的错误。 更新: 我用的时候 page.driver.browser.window_handles.each do |handle| page.driver.browser.switch_to.window(handle) page.driver.browser.close end 它给出以下错误Selenium::WebDriver::Error::UnknownError: ‘auto_id’不引用打开的选项卡

Heroku:使用Watir / Selenium时无法连接到chromedriver 127.0.0.1:9515

它在本地运行(不指定driver_path ),但不在Heroku上运行。 码: Selenium::WebDriver::Chrome.driver_path = ENV[‘GOOGLE_CHROME_SHIM’] browser = Watir::Browser.new :chrome 我在heroku rails控制台中确认了以下值 ENV[‘GOOGLE_CHROME_BIN’] => “/app/.apt/opt/google/chrome/chrome” ENV[‘GOOGLE_CHROME_SHIM’] => “/app/.apt/usr/bin/google-chrome-stable” 已安装的Buildpacks: https://github.com/heroku/heroku-buildpack-chromedriver https://github.com/heroku/heroku-buildpack-google-chrome 当前错误: Selenium :: WebDriver :: Error :: WebDriverError:无法连接到chromedriver 127.0.0.1:9515 在SO上搜索unable to connect to chromedriver 127.0.0.1:9515返回一堆结果,但没有提到heroku。 也: 我考虑过phantomjs。 其他人在这里工作, 使用带有Heroku Rails Unicorn堆栈的无头浏览器 但它被弃用了。 在本地运行时出现以下错误。 不推荐使用PhantomJS的Selenium支持。 请改用无头Chrome / Firefox或HTMLUnit。 也试过: 为了透明,我也尝试了以下内容。 更改browser = Watir::Browser.new :chrome browser […]

如何使用auth将代理添加到Watir上的ChromeDriver

我在Ruby上使用Watir,它使用Selenium作为其底层框架。 我正在使用ChromeDriver,为了设置代理,我真的这样做了: b = Watir::Browser.new :chrome, :switches => [“–proxy-server=11.1.1.11:3011”] 有时,代理附带用户,密码validation如下: 11.1.1.11:3011:3011:user:pass 但是当我尝试将该字符串放入–proxy-server我收到一个错误。 如何配置ChromeDriver以使用身份validation? 我尝试过其他SO答案中经常提出的格式,即: http://user:pass@11.1.1.11:3011 但那没用。 尝试没有http部分,也没有工作。

无法启动子进程

当我尝试在Chrome(selenium / Ruby)上运行测试时,我收到以下错误。 有人可以帮忙解决这个问题吗? 错误: – 背景:登录到app#tests \ integration \ channels.feature:3 [6100:7920:1028/134946:错误:child_process_launcher.cc(533)]无法启动子进程[6100:9520:1028/134946:错误:child_process_launcher .cc(533)]无法启动子进程[6100:9520:1028/134946:错误:child_process_launcher.cc(533)]无法启动子进程[6100:9520:1028/134949:错误:child_process_launcher.cc(533) )]无法启动子进程[6100:9520:1028/134955:错误:child_process_launcher.cc(533)]无法启动子进程[6100:9520:1028/135006:错误:child_process_launcher.cc(533)]失败启动子进程耙子中止! 以下是安装的gem: – * LOCAL GEMS * bigdecimal (default: 1.2.0) builder (3.2.2) bundle (0.0.1) bundler (1.13.6, 1.11.2) childprocess (0.5.0) cucumber (2.4.0, 1.3.2) cucumber-core (1.5.0) cucumber-wire (0.0.1) debase (0.2.1, 0.1.4) debase-ruby_core_source (0.9.2) diff-lcs (1.2.5) ffi (1.9.14 x86-mingw32) gherkin (4.0.0, 2.12.2 x86-mingw32) io-console (default: […]

运行测试时,Chrome驱动程序控制台输出会变得沉寂

我使用的是最新版本的Chrome(32.0.1700.107)和Chrome驱动程序(V2.8)。 但是当我在Ruby中使用以下代码运行我的示例测试时: require ‘selenium-webdriver’ WAIT = Selenium::WebDriver::Wait.new(timeout: 100) $driver = Selenium::WebDriver.for :chrome $driver.manage.window.maximize $driver.navigate.to ‘https://www.google.co.in’ def apps_hover ele_hover = $driver.find_element(:xpath, “.//*[@id=’gbwa’]/div[1]/a”) $driver.action.move_to(ele_hover).perform sleep 5 puts”Pass” end apps_hover $driver.quit() 我从一开始就从chrome驱动程序获得控制台输出,如下所示: [5032:4816:0218/130016:错误:chrome_views_delegate.cc(176)]未实现[5032:4816:0218/130016:错误:desktop_root_window_host_win.cc(746)]未实现[5032:4816:0218/130016:错误:desktop_root_window_host_win.cc(746)]未实现。 有没有办法让这些控制台输出静音?

如何在无头Chrome上使用Selenium Webdriver?

我正在学习使用Selenium来做基本的事情,例如截取屏幕,抓取和测试,并希望将它与无头Chrome一起使用,Chrome现在从Chrome 59开始就是稳定的。 我已经能够使用’selenium-webdriver’gem和chromedriver截取屏幕截图,但不是无头。 这是我正在运行的ruby脚本,它在开始初始化驱动程序后挂起 require ‘rubygems’ require ‘selenium-webdriver’ Selenium::WebDriver.logger.level = :debug p ‘initializing driver’ driver = Selenium::WebDriver.for :chrome, switches: %w[–headless –disable-gpu –screenshot –hide-scrollbars] p ‘navigating to Google’ driver.navigate.to “http://google.com” driver.save_screenshot(“./screen.png”) driver.quit 和日志的输出: :> ruby rubytest.rb “initializing driver” 2017-06-07 15:55:43 DEBUG Selenium Executing Process [“/Users/name/Documents/scrapings/python/env/bin/chromedriver”, “–port=9515”] 2017-06-07 15:55:43 DEBUG Selenium polling for socket on [“127.0.0.1”, 9515] […]

使无头浏览器停止加载页面

我正在使用watir-webdriver ruby​​ gem。 它启动浏览器(Chrome)并开始加载页面。 页面加载太慢,watir-webdriver引发超时错误。 如何让浏览器停止加载页面? require ‘watir-webdriver’ client = Selenium::WebDriver::Remote::Http::Default.new client.timeout = 10 @browser = Watir::Browser.new :chrome, :http_client => client sites = [ “http://google.com/”, “http://yahoo.com/”, “http://www.nst.com.my/”, # => This is the SLOW site “http://drupal.org/”, “http://www.msn.com/”, “http://stackoverflow.com/” ] sites.each do |url| begin @browser.goto(url) puts “Success #{url}” rescue puts “Timeout #{url}” end end ########## Execution result […]

通过Ruby WebDriver获取chromes控制台日志

此问题之前已在Java中得到解答( Get chrome的控制台日志 ) 但是,我正在使用Ruby绑定,并想知道是否提供了类似的function? 我查看了Ruby源代码,但看不到任何提及或引用LoggingPreferences。 顺便说一句,我正在使用RemoteWebDriver并传入所需的function对象。 据推测,我想在该对象中设置日志记录首选项,但我很难看到哪里。