Selenium Webdriver Chromedriver timeout on startup in silent mode

I am using Selenium Webdriver, with Ruby 32-bit 1.9.3, Chromedriver v2.9.248315, Chrome 38.0.2125.111 m and local Jenkins 1.588 instance

Gems: cucumber (1.3.17), selenium-webdriver (2.43.0), watir-webdriver (0.6.11) (can provide a list of all the others if you see fit)

Windows 7 Professional 64-bit.

When starting a Jenkins job that starts Chrome using chromedriver and then tries to interact with it, I get a timeout error. When you do the same on my desktop via a command prompt window, it works great. Doing the same Jenkins job by running Firefox instead of Chrome it works great.

Simple example (C: \ test.rb):

require 'watir-webdriver'
require 'selenium-webdriver'
client = Selenium::WebDriver::Remote::Http::Default.new
$browser = Watir::Browser.new :chrome, :http_client => client
$browser.driver.manage.window.maximize
$browser.close

      

Jenkins task configured to run Windows command line:

cd \
ruby test.rb

      

Result when starting the task:

Started by user anonymous
Building in workspace C:\Program Files (x86)\Jenkins\jobs\test chromedriver\workspace
[workspace] $ cmd /c call C:\Windows\TEMP\hudson3963234995624341455.bat

C:\Program Files (x86)\Jenkins\jobs\test chromedriver\workspace>cd \ 

C:\>ruby test.rb 
C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:146:in `rescue in rbuf_fill': Timeout::Error (Timeout::Error)
    from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:140:in `rbuf_fill'
    from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:122:in `readuntil'
    from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:132:in `readline'
    from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:2563:in `read_status_line'
    from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:2552:in `read_new'
    from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1320:in `block in transport_request'
    from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1317:in `catch'
    from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1317:in `transport_request'
    from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1294:in `request'
    from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1287:in `block in request'
    from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:746:in `start'
    from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1285:in `request'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.43.0/lib/selenium/webdriver/remote/http/default.rb:83:in `response_for'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.43.0/lib/selenium/webdriver/remote/http/default.rb:39:in `request'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.43.0/lib/selenium/webdriver/remote/http/common.rb:40:in `call'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.43.0/lib/selenium/webdriver/remote/bridge.rb:638:in `raw_execute'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.43.0/lib/selenium/webdriver/remote/bridge.rb:616:in `execute'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.43.0/lib/selenium/webdriver/remote/bridge.rb:236:in `maximizeWindow'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.43.0/lib/selenium/webdriver/common/window.rb:98:in `maximize'
    from test.rb:5:in `<main>'

C:\>exit 1 
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE

      

I tried to enable "Allow the service to interact with the desktop" in the Jenkins service and then see the window (in a more complex scenario) and open the Chrome window, but it doesn't do anything. I originally had a problem with "$ browser.cookies.clear" and after commenting out that line now I have the same problem with the $ browser.driver.manage.window.maximize line

I've run complex cucumber scripts with no problem using Chromedriver. Then I rebooted my machine and after installing Jenkins, Ruby, Chromedriver (adding both to PATH) and copying the old jobs to my new Jenkins installation, I got the problem above. Then I created a simple example above, tested it and created this post.

If anyone has any ideas on how I can get Chromedriver running again that would be great.

+3


source to share


3 answers


Chrome 38 doesn't work when running as a system user in session 0. This usually happens because Chrome is started by a Windows service - in your case Jenkins, which is started as a service. This is a known issue. See Selenium here and here .

Two solutions:



AlwaysUp definitely works, but has a low license cost, or if you're not worried about the version of Chrome, you can downgrade it.

+5


source


Chrome cannot run in headless window mode. you need to use HTMLdriver for this.



If you really need it, you need to try installing the vnc server and starting it. http://www.installationpage.com/selenium/how-to-run-selenium-headless-firefox-in-ubuntu/

+1


source


SDET answer helped me (raised), session 0 was my problem, but you don't need AlwaysUp, you can just start jenkins slave from some startup script by: javaws http://<jenkins-master>/computer/<node-name>/slave-agent.jnlp

0


source







All Articles