seleniumbase / SeleniumBase

📊 Python's all-in-one framework for web crawling, scraping, testing, and reporting. Supports pytest. UC Mode provides stealth. Includes many tools.
https://seleniumbase.io
MIT License
4.45k stars 908 forks source link

uc_open_with_reconnect website is closing window #2830

Closed stuckinthe closed 4 weeks ago

stuckinthe commented 4 weeks ago

I've been using SeleniumBase for awhile without issue and then all of a sudden today. The website must be detecting SB and closing the window as I get a window already closed when trying to grab the page source. Running Arch Linux Aarch64 on a RPi 5. Using chromium as this is the only chrome package I have

ChromeDriver 122.0.6261.129 Chromium 122.0.6261.128 Arch Linux ARM

I haven't changed anything on my system since yesterday.

Anyone can point me in the right direction on how to solve this.

from seleniumbase import Driver
driver = Driver(uc=True)
driver.uc_open_with_reconnect('https://example.com/')
html = driver.page_source
selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
from unknown error: web view not found
mdmintz commented 4 weeks ago

I didn't see any issues when I ran your script:

from seleniumbase import Driver
driver = Driver(uc=True)
driver.uc_open_with_reconnect('https://example.com/')
html = driver.page_source
driver.quit()

However, note that you should use google-chrome-stable or google-chrome, not chromium on Linux if you want to remain undetected. Also, you probably want to use the SB() format instead with xvfb=True:

with SB(uc=True, xvfb=True) as sb:
   # ...

That will handle running a headed browser on a headless display.

stuckinthe commented 4 weeks ago

Thanks for the help. The Arm Arch doesn't have a google-chrome package. I have tried it again with the added true statement. The website must be doing something as it just started happening.

from seleniumbase import Driver driver = Driver(uc=True, xvfb=True) driver.uc_open_with_reconnect('https://example.com/') html = driver.page_source driver.quit()

mdmintz commented 4 weeks ago

Driver() does not have the xvfb arg. You need to use SB() for that.

stuckinthe commented 3 weeks ago

Unfortunately, I get a cannot connect to chrome error with SB()

But this works without issue

from seleniumbase import Driver driver = Driver(uc=True) driver.get('https://google.com/')