Handling Unexpected Tab Closure and Navigation Issues with SeleniumBase #2330
-
Hi, I am using SeleniumBase for web automation and have encountered an issue where occasionally driver.get(url) results in the current tab being closed and a new tab being opened. This behavior causes a loss of the previous page's context, including its scroll position. I attempted to use driver.execute_script("window.history.go(-1)") to navigate back, but it doesn't work if the original tab is closed. Is this a known behavior with SeleniumBase, or could it be related to specific browser settings or website behavior? Also, is there a way to ensure navigation happens within the same tab and to retain the scroll position of the previous page? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hello. What you're describing is the default behavior in UC Mode when you use You can use This is all covered in: |
Beta Was this translation helpful? Give feedback.
Hello. What you're describing is the default behavior in UC Mode when you use
driver.get(url)
to open a URL that has bot-detection software running on it. The current tab is replaced with a clean one (that doesn't have any traces of Selenium from within the Chrome browser console) and the new URL is opened.You can use
driver.default_get(url)
to open the new URL in the current tab without using UC Mode. Or you can trydriver.uc_open(url)
, which has better anti-detection mechanisms thandriver.default_get(url)
, but it's not as good asdriver.get(url)
/driver.uc_open_with_tab(url)
/driver.uc_open_with_reconnect(url, reconnect_time)
(which close the current tab and open a new one).This is…