-
Below is a test to show this behavior. This issue happened to me when i was trying to fill out a form on a second tab using uc mode. from seleniumbase import Driver
from selenium.webdriver.common.by import By
driver = Driver(uc=True)
try:
driver.get("https://www.freecodecamp.org/news/how-to-use-html-to-open-link-in-new-tab/")
print("Start", '\n', driver.current_url, '\n')
new_tab_link = driver.find_element(By.XPATH, '//a[@target="_blank" and contains(text(), "freeCodeCamp")]')
new_tab_link.uc_click()
anchor_handle = driver.current_window_handle
tabs = driver.window_handles
for handle in tabs:
driver.switch_to.window(handle)
if driver.current_window_handle != anchor_handle:
break
# confirming driver is on the second tab
print("Switched to second tab", '\n', driver.current_url, '\n')
getstarted_btn = driver.find_element(By.XPATH, '//a[@href="https://api.freecodecamp.org/signin"]/span[contains(text(), "Get started (it\'s free)")]')
getstarted_btn.uc_click()
# confirming driver reconnected to first tab
print("After uc_click in second tab", '\n', driver.current_url)
finally:
driver.quit() P.S. I sure you had a blast at the Star Trek convention! I hope you wore your engineering uniform 🖖🏻 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
For stealth, one component of To avoid tab-reordering, use a single tab for UC Mode scripts. More info: #2328 (comment) The Star Trek convention was great! Already posted photos with Jonathan Frakes and LeVar Burton: #2785 (comment) Here's a few more photos from the set tour: I'll post videos with Jonathan Frakes and LeVar Burton later on YouTube. I spoke with them and Walter Koenig. |
Beta Was this translation helpful? Give feedback.
For stealth, one component of
uc_click
is reconnecting chromedriver to Chrome. This can change tab-order if multiple tabs are open because variables are lost during the disconnect (controlled by raw Selenium, not SeleniumBase).To avoid tab-reordering, use a single tab for UC Mode scripts. More info: #2328 (comment)
The Star Trek convention was great! Already posted photos with Jonathan Frakes and LeVar Burton: #2785 (comment)
Here's a few more photos from the set tour:
I'll post videos with Jonathan Frakes and LeVar Burton later on YouTube. I spoke with them and Walter Koenig.