Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

driver.reset! triggers a Selenium::WebDriver::Error::ScriptTimeoutError #2535

Closed
marcoadkins opened this issue Mar 16, 2022 · 3 comments
Closed

Comments

@marcoadkins
Copy link

marcoadkins commented Mar 16, 2022

Meta

Capybara Version: 3.36.0

Driver Information: selenium-webdriver 4.1.0 with Google Chrome 96.0.4664.93

OS: macOS Big Sur

Expected Behavior

Capybara.current_session.driver.reset! does not throw an exception when trying to clear cookies and local storage.

Actual Behavior

(byebug) Capybara.current_session.driver.reset!
*** Selenium::WebDriver::Error::ScriptTimeoutError Exception: Unable to execute request for an existing session: POST /session/9c2e8f72783418513a46e4354f9fd08f/goog/cdp/execute
Build info: version: '4.1.0', revision: '87802e897b'
System info: host: 'c202f6697df7', ip: '172.18.0.11', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.47-linuxkit', java.version: '11.0.11'
Driver info: driver.version: unknown

Steps to reproduce

No specific details to reproduce. Here is my configuration though that might be able to help replicate the problem.


# Driver setup
Capybara.register_driver :selenium_chrome_headless do |app|
  capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
    acceptInsecureCerts: true,
    'goog:chromeOptions': {
      args: %W[
        headless
        proxy-server=#{ENV['CI'] ? 'localhost' : ENV.fetch('NGINX_IP')}:#{Billy.proxy.port}
        window-size=1440,900
      ],
      prefs: {
        download: {
          default_directory: DownloadSpecHelpers::CHROME_PATH
        }
      },
      w3c: false
    },
    'goog:loggingPrefs': {
      browser: 'ALL'
    }
  )

  options = {
    browser: ENV['CI'] ? :chrome : :remote,
    capabilities: capabilities,
    url: 'http://localhost:4445/wd/hub'
  }

  Capybara::Selenium::Driver.new(app, options).tap do |d|
    unless ENV['CI']
      d.browser.file_detector = lambda do |args|
        str = args.first.to_s
        str if File.exist?(str)
      end
    end
  end
end

Relevant log output

Deeper Stacktrace triggered in rspec run:
     1.1) Failure/Error: Capybara.reset! unless example.exception (rails_helper.rb:89)

          Selenium::WebDriver::Error::ScriptTimeoutError:
            Unable to execute request for an existing session: POST /session/71459489cd31d6928048675764dc467b/goog/cdp/execute
            Build info: version: '4.1.0', revision: '87802e897b'
            System info: host: 'c202f6697df7', ip: '172.18.0.11', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.47-linuxkit', java.version: '11.0.11'
            Driver info: driver.version: unknown
          # java.lang.RuntimeException: Unable to execute request for an existing session: POST /session/71459489cd31d6928048675764dc467b/goog/cdp/execute
          # Build info: version: '4.1.0', revision: '87802e897b'
          # System info: host: 'c202f6697df7', ip: '172.18.0.11', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.47-linuxkit', java.version: '11.0.11'
          # Driver info: driver.version: unknown
          # 	at org.openqa.selenium.grid.router.HandleSession.execute(HandleSession.java:139)
          # 	at org.openqa.selenium.remote.http.Route$PredicatedRoute.handle(Route.java:373)
          # 	at org.openqa.selenium.remote.http.Route.execute(Route.java:68)
          # 	at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)
          # 	at org.openqa.selenium.remote.http.Route.execute(Route.java:68)
          # 	at org.openqa.selenium.grid.router.Router.execute(Router.java:91)
          # 	at org.openqa.selenium.grid.web.EnsureSpecCompliantResponseHeaders.lambda$apply$0(EnsureSpecCompliantResponseHeaders.java:34)
          # 	at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)
          # 	at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)
          # 	at org.openqa.selenium.remote.http.Route.execute(Route.java:68)
          # 	at org.openqa.selenium.remote.http.Route$NestedRoute.handle(Route.java:270)
          # 	at org.openqa.selenium.remote.http.Route.execute(Route.java:68)
          # 	at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)
          # 	at org.openqa.selenium.remote.http.Route.execute(Route.java:68)
          # 	at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)
          # 	at org.openqa.selenium.remote.http.Route.execute(Route.java:68)
          # 	at org.openqa.selenium.remote.AddWebDriverSpecHeaders.lambda$apply$0(AddWebDriverSpecHeaders.java:35)
          # 	at org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)
          # 	at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)
          # 	at org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)
          # 	at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)
          # 	at org.openqa.selenium.netty.server.SeleniumHandler.lambda$channelRead0$0(SeleniumHandler.java:44)
          # 	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
          # 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
          # 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
          # 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
          # 	at java.base/java.lang.Thread.run(Thread.java:829)
          # ./spec/rails_helper.rb:200:in `block (2 levels) in <top (required)>'

Relevant Selenium Logger Output:

2022-03-16 09:49:28 INFO Selenium -> POST session/bb0994cc75b38f0e33f96c2620f47680/url
2022-03-16 09:49:28 INFO Selenium    >>> http://localhost:4445/wd/hub/session/bb0994cc75b38f0e33f96c2620f47680/url | {"url":"about:blank"}
2022-03-16 09:49:28 INFO Selenium <- {
  "value": null
}
2022-03-16 09:49:28 INFO Selenium -> POST session/bb0994cc75b38f0e33f96c2620f47680/elements
2022-03-16 09:49:28 INFO Selenium    >>> http://localhost:4445/wd/hub/session/bb0994cc75b38f0e33f96c2620f47680/elements | {"using":"xpath","value":"/html/body/*"}
2022-03-16 09:49:28 INFO Selenium <- {
  "value": [
  ]
}
2022-03-16 09:49:28 INFO Selenium -> POST session/bb0994cc75b38f0e33f96c2620f47680/goog/cdp/execute
2022-03-16 09:49:28 INFO Selenium    >>> http://localhost:4445/wd/hub/session/bb0994cc75b38f0e33f96c2620f47680/goog/cdp/execute | {"cmd":"Storage.clearDataForOrigin","params":{"origin":"*","storageTypes":"cookies,local_storage"}}
2022-03-16 09:49:28 INFO Selenium <- {
  "value": {
    "error": "script timeout",
    "message": "Unable to execute request for an existing session: POST \u002fsession\u002fbb0994cc75b38f0e33f96c2620f47680\u002fgoog\u002fcdp\u002fexecute\nBuild info: version: '4.1.0', revision: '87802e897b'\nSystem info: host: '4b975b71dd55', ip: '172.18.0.3', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.47-linuxkit', java.version: '11.0.11'\nDriver info: driver.version: unknown",
    "stacktrace": "java.lang.RuntimeException: Unable to execute request for an existing session: POST \u002fsession\u002fbb0994cc75b38f0e33f96c2620f47680\u002fgoog\u002fcdp\u002fexecute\nBuild info: version: '4.1.0', revision: '87802e897b'\nSystem info: host: '4b975b71dd55', ip: '172.18.0.3', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.47-linuxkit', java.version: '11.0.11'\nDriver info: driver.version: unknown\n\tat org.openqa.selenium.grid.router.HandleSession.execute(HandleSession.java:139)\n\tat org.openqa.selenium.remote.http.Route$PredicatedRoute.handle(Route.java:373)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.grid.router.Router.execute(Router.java:91)\n\tat org.openqa.selenium.grid.web.EnsureSpecCompliantResponseHeaders.lambda$apply$0(EnsureSpecCompliantResponseHeaders.java:34)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.remote.http.Route$NestedRoute.handle(Route.java:270)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.remote.AddWebDriverSpecHeaders.lambda$apply$0(AddWebDriverSpecHeaders.java:35)\n\tat org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.netty.server.SeleniumHandler.lambda$channelRead0$0(SeleniumHandler.java:44)\n\tat java.base\u002fjava.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)\n\tat java.base\u002fjava.util.concurrent.FutureTask.run(FutureTask.java:264)\n\tat java.base\u002fjava.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)\n\tat java.base\u002fjava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)\n\tat java.base\u002fjava.lang.Thread.run(Thread.java:829)\n"
  }
}

Related Selenium Issue:

@marcoadkins
Copy link
Author

Update: removing the w3c: false setting resolved the error for me.

@titusfortner
Copy link

@twalpole why does Capybara send the command directly if the browser doesn't respond to #execute_cdp? Curious the conditions where that is needed.

@twalpole
Copy link
Member

@titusfortner that was support for a previous version of selenium before it had execute_cdp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants