SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.63k stars 8.18k forks source link

[🐛 Bug]: selenium.common.exceptions.InvalidSessionIdException: Message: invalid session id #12245

Closed kingrapha closed 1 year ago

kingrapha commented 1 year ago

What happened?

Python language bindings for selenium WebDriver raises a selenium.common.exceptions.InvalidSessionIdException: Message: invalid session id. The browser is closed without triggering driver.quit() or driver.close() yet.

This on selenium grid 4.9.1 configured in kubernetes cluster using helm chart selenium-grid-0.18.0 with keda auto scaling. In values.yaml file: ChromeNode: extraEnvironmentVariables:

How can we reproduce the issue?

options = Options()
options.add_argument(—-no-sandox’)
options.add_argument(—-disable-infoxbars’)
options.add_argument(—-disable-hang-monitor’)
options.add_argument(—-disable-setuid-sandbox’)
options.add_argument(—-disable-dev-shm-usage’)

caps = {‘browserName’: ‘chrome’, ‘platformName’: ‘LINUX’, ‘acceptInsecureCerts’: True}

driver = webdriver.remote(command_executor= https://selenium-grid-url, desired_capabilities=caps, options= options)
try:
   driver.get(“testing application url”)
   wait = WebDriverWait(driver, 60)
   element = wait.until(EC.element_to_be_clickable((By.ID,”locator”)
   element.click()
   wait.until(EC.invisibility_of_element_located((By.ID, “loading-bar”)
   ………more test code……
finally:
   driver.quit()

Relevant log output

raise exception_class(message, screen, stacktrace)

selenium.common.exceptions.InvalidSessionIdException: Message: invalid session id

Operating System

Linux

Selenium version

4.9.1

What are the browser(s) and version(s) where you see this issue?

Chrome, 113

What are the browser driver(s) and version(s) where you see this issue?

Chrome webdriver version 113

Are you using Selenium Grid?

4.9.1

github-actions[bot] commented 1 year ago

@kingrapha, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

diemol commented 1 year ago

This has been several times reported and most of the time is the lack of configuration, please read https://www.selenium.dev/blog/2022/scaling-grid-with-keda/ and check your settings. We are merging a PR with Keda integration soon so this should be more straightforward.

github-actions[bot] commented 1 year ago

💬 Please ask questions at:

github-actions[bot] commented 10 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.