-
Notifications
You must be signed in to change notification settings - Fork 917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Selemiumbase Driver switches to another tab #2328
Comments
Update: it happens only with one of those: |
Even regular
Tab-switching works differently in UC Mode. (The standard SeleniumBase formats have additional methods for that.) Here's an example of that: from seleniumbase import SB
with SB(uc=True) as sb:
sb.driver.uc_open_with_tab("data:text/html,<h1>Page A</h1>")
sb.assert_text("Page A")
sb.open_new_window()
sb.driver.uc_open_with_tab("data:text/html,<h1>Page B</h1>")
sb.assert_text("Page B")
sb.switch_to_window(0)
sb.assert_text("Page A")
sb.assert_text_not_visible("Page B")
sb.switch_to_window(1)
sb.assert_text("Page B")
sb.assert_text_not_visible("Page A") If you need more than one tab open, first call Also note that having more than one tab open at a time will likely lead to Selenium detection, so you're probably better off having only one tab/window open at a time for tests. |
@mdmintz
|
Those URLs appear to have redirects in them. It's tricky enough for UC Mode to manage tabs after a disconnect because chromedriver is completely disconnected from Chrome during the disconnect/reconnect process. That can cause tab order to change. Also, UC Mode anti-detection likely won't work when using multiple tabs. Therefore, when using UC Mode, try to run your script using a single tab/window. |
After opening those three tabs, the driver switches from the third tab to the second one or the first one.
It doesn't happen with the selenium driver nor the uc_chromedriver.
I managed to reproduce the bug with the following code:
happened on Python 3.9 & 3.11.6
from seleniumbase import Driver
AMAZON_PRIME_LOGIN = "https://www.amazon.com/ap/signin?openid.pape.max_auth_age=3600&openid.return_to=https%3A%2F%2Fgaming.amazon.com%2Fprime%2Fsignup%2Feg%3Fingress%3Damzn%26ref_%3Dsm_w_ics_m_f_all&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.assoc_handle=amzn_respawn_desktop_us&openid.mode=checkid_setup&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&ssoResponse=eyJ6aXAiOiJERUYiLCJlbmMiOiJBMjU2R0NNIiwiYWxnIjoiQTI1NktXIn0.yf9Wgo4I2tZaftdNDV9dGzDE3WBRtCwlofy9T0xdJFn6Z8J9GkkQ2A.YfhrqNQaRSrDgXpJ.5jj055CVEHpYJa2zcCUKxxPSxxcSeVjvQFpUjEP-_kOek_h1S8Zy6jujXVJSGJtsliAleSPGnrlvysESKkSEXnAWFOvJRcE9JepYQJulvu"
AMAZON_PRIME_GAMING = "https://gaming.amazon.com/prime-gaming-capsule-nov-23/dp/amzn1.pg.item.fe075900-6304-4e90-a13d-d5e04635dca9?ingress=amzn&ref_=SM_LeagueofLegends_S13_D09_CRWN"
AMAZON_NUMBER_SETTING = "https://www.amazon.com/ap/profile/mobilephone?ref_=ax_am_landing_add_mobile&openid.assoc_handle=usflex&referringAppAction=CNEP"
driver = Driver(uc= True)
driver.get(AMAZON_PRIME_LOGIN)
driver.switch_to.new_window('tab')
driver.get(AMAZON_PRIME_GAMING)
driver.switch_to.new_window('tab')
driver.get(AMAZON_NUMBER_SETTING)
input()
driver.quit()
The text was updated successfully, but these errors were encountered: