Closed davidAlgis closed 1 week ago
UC Mode (uc=True
) is for Chrome only, although it can also work on some of the other Chromium browsers (eg. Brave
, Opera
) by setting the binary_location
.
Firefox, Safari, and Edge won't work with UC Mode (you set the browser
to firefox
). Therefore the UC Mode specific methods (such as uc_open_*
) won't exist.
Thanks for your answer ! That's interesting, because at first I was using the "classical" selenium module, but it wasn't working for some reason and I switch to seleniumbase to try if it works, I was completely sure it works because of the UC mode, but as you mention it I just notice that it doesn't change anything. Could you explain to me what is the difference then between selenium and seleniumbase if the uc mode is disabled ? Moreover, have you an idea how to open a new tab without uc mode but with Driver ?
The SeleniumBase driver
has the original driver
methods, plus new ones.
Here's an example of a script that opens a new tab with the Driver()
manager:
from seleniumbase import Driver
driver = Driver()
try:
driver.open("data:text/html,<h1>Page A</h1>")
driver.assert_text("Page A")
driver.switch_to.new_window("tab")
driver.open("data:text/html,<h1>Page B</h1>")
driver.assert_text("Page B")
driver.switch_to.window(driver.window_handles[0])
driver.assert_text("Page A")
driver.switch_to.window(driver.window_handles[1])
driver.assert_text("Page B")
finally:
driver.quit()
And since that script runs really fast, here's the same script with waits:
from seleniumbase import Driver
driver = Driver()
try:
driver.sleep(1)
driver.open("data:text/html,<h1>Page A</h1>")
driver.assert_text("Page A")
driver.sleep(1)
driver.switch_to.new_window("tab")
driver.sleep(1)
driver.open("data:text/html,<h1>Page B</h1>")
driver.assert_text("Page B")
driver.sleep(1)
driver.switch_to.window(driver.window_handles[0])
driver.assert_text("Page A")
driver.sleep(1)
driver.switch_to.window(driver.window_handles[1])
driver.assert_text("Page B")
driver.sleep(1)
finally:
driver.quit()
It works like a charm. Thank you a lot !
I'm trying to open a new tab in uc mode with Driver. Here is my code:
After it has launched the browser windows, it throws the following error:
If I use
get
instead ofuc_open_with_tab
it works perfectly.