SeleniumHQ / selenium

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

[🐛 Bug]: Can't move a Selenium driver to VNC window #12775

Closed CalebKierum closed 1 year ago

CalebKierum commented 1 year ago

What happened?

I have a selenium driver I created from SSH. To do this I had to create a fake display which I did via pyvirtualdisplay

from pyvirtualdisplay import Display
display = Display(visible=0, size=(1920, 1920))
display.start()
driver = webdriver.Chrome()

Now I can tell that driver is still awake because I can connect to it and get it to load pages with WebDriverWait.Remote() however when I go into vnc and write the following code I get the following crash. The window does not move into VNC nor can I see the Chromium instance in the task bar

driver.switch_to.window(webdriver.Chrome().current_window_handle)

How can we reproduce the issue?

Run this code where driver is a driver created in an SSH instance with pyvirtualdisplay

`driver.switch_to.window(webdriver.Chrome().current_window_handle)`

Relevant log output

68, in <module>
    driver.switch_to.window(trashDriver.current_window_handle)
  File "/home/caleb/.local/lib/python3.9/site-packages/selenium/webdriver/remote/switch_to.py", line 133, in window
    self._w3c_window(window_name)
  File "/home/caleb/.local/lib/python3.9/site-packages/selenium/webdriver/remote/switch_to.py", line 141, in _w3c_window
    send_handle(window_name)
  File "/home/caleb/.local/lib/python3.9/site-packages/selenium/webdriver/remote/switch_to.py", line 137, in send_handle
    self._driver.execute(Command.SWITCH_TO_WINDOW, {"handle": h})
  File "/home/caleb/.local/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 344, in execute
    self.error_handler.check_response(response)
  File "/home/caleb/.local/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchWindowException: Message: no such window
  (Session info: chrome=113.0.5672.95)
Stacktrace:
#0 0x000001096884 <unknown>
#1 0x000000dd85e0 <unknown>
#2 0x000000e4877c <unknown>
#3 0x000000e3b964 <unknown>
#4 0x000000e0bf08 <unknown>
#5 0x000000e0d108 <unknown>
#6 0x00000105b968 <unknown>
#7 0x00000105ec68 <unknown>
#8 0x00000105e5dc <unknown>
#9 0x00000105f354 <unknown>
#10 0x000001066f8c <unknown>
#11 0x00000105f7cc <unknown>
#12 0x000001038768 <unknown>
#13 0x00000107fd5c <unknown>
#14 0x00000107fee8 <unknown>
#15 0x000001090364 <unknown>
#16 0x0000f7dd6310 start_thread
#17 0x000000000000 <unknown>

Operating System

Pi OS

Selenium version

4.12.0

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

Chromium

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

ChromeDriver

Are you using Selenium Grid?

No response

github-actions[bot] commented 1 year ago

@CalebKierum, 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!

titusfortner commented 1 year ago

A driver can only navigate to a window it has created.

github-actions[bot] commented 11 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.