Search code examples
seleniumrspeccapybararspec-rails

How to resolve Failure/Error: raise Error::ServerError, self Selenium::WebDriver::Error::ServerError: status code 404


I am using Rspec with Capybara and selenium-webdriver gems for my tests. Tests are running perfectly fine on my local machine. But when i try to execute on GITLAB CI, those got failed with below errors.

            Selenium::WebDriver::Error::ServerError:
              status code 404
            # /usr/local/bundle/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver/remote/response.rb:60:in `assert_ok'
            # /usr/local/bundle/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver/remote/response.rb:35:in `initialize'
            # /usr/local/bundle/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver/remote/http/common.rb:83:in `new'
            # /usr/local/bundle/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver/remote/http/common.rb:83:in `create_response'
            # /usr/local/bundle/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver/remote/http/default.rb:109:in `request'
            # /usr/local/bundle/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver/remote/http/common.rb:59:in `call'
            # /usr/local/bundle/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver/remote/bridge.rb:588:in `execute'
            # /usr/local/bundle/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver/remote/bridge.rb:206:in `window_handles'
            # /usr/local/bundle/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver/common/driver.rb:203:in `window_handles'
            # /usr/local/bundle/gems/capybara-3.36.0/lib/capybara/selenium/driver.rb:253:in `window_handles'
            # /usr/local/bundle/gems/capybara-3.36.0/lib/capybara/selenium/driver_specializations/chrome_driver.rb:40:in `reset!'
            # /usr/local/bundle/gems/capybara-3.36.0/lib/capybara/session.rb:130:in `reset!'
            # /usr/local/bundle/gems/capybara-3.36.0/lib/capybara.rb:325:in `block in reset_sessions!'
            # /usr/local/bundle/gems/capybara-3.36.0/lib/capybara.rb:325:in `reverse_each'
            # /usr/local/bundle/gems/capybara-3.36.0/lib/capybara.rb:325:in `reset_sessions!'
            # /usr/local/bundle/gems/capybara-3.36.0/lib/capybara/rspec.rb:20:in `block (2 levels) in <top (required)>' ```



What could be the possible reason. Thank you

Solution

  • I resolved that issue by increasing the selenium session for the chrome driver. In my case it the remote selenium chrome node was running in docker so I just increased the timeout with the env variable SE_NODE_SESSION_TIMEOUT=999999. In your case the following might help increase timeout for selenium on gitlab ci.

    logs with the same issue