Closed
Description
Add support for uc_gui_handle_cf()
with Driver()
and DriverContext()
formats
Currently, if running this code:
from seleniumbase import DriverContext
with DriverContext(uc=True) as driver:
url = "https://www.virtualmanager.com/en/login"
driver.uc_open_with_reconnect(url, 4)
driver.uc_gui_handle_cf() # Ready if needed!
driver.assert_element('input[name*="email"]')
driver.assert_element('input[name*="login"]')
That leads to this stack trace:
File "/Users/michael/github/SeleniumBase/seleniumbase/core/browser_launcher.py", line 4025, in <lambda>
lambda *args, **kwargs: uc_gui_handle_cf(
^^^^^^^^^^^^^^^^^
File "/Users/michael/github/SeleniumBase/seleniumbase/core/browser_launcher.py", line 651, in uc_gui_handle_cf
install_pyautogui_if_missing()
File "/Users/michael/github/SeleniumBase/seleniumbase/core/browser_launcher.py", line 559, in install_pyautogui_if_missing
verify_pyautogui_has_a_headed_browser()
File "/Users/michael/github/SeleniumBase/seleniumbase/core/browser_launcher.py", line 552, in verify_pyautogui_has_a_headed_browser
if sb_config.headless or sb_config.headless2:
^^^^^^^^^^^^^^^^^^
AttributeError: module 'seleniumbase.config' has no attribute 'headless'
Here's the workaround for now using SB()
: (Which includes the virtual display needed on Linux)
from seleniumbase import SB
with SB(uc=True) as sb:
url = "https://www.virtualmanager.com/en/login"
sb.uc_open_with_reconnect(url, 4)
sb.uc_gui_handle_cf() # Ready if needed!
sb.assert_element('input[name*="email"]')
sb.assert_element('input[name*="login"]')
Once this ticket is resolved, Linux users who use Driver()
or DriverContext
formats in UC Mode will still need to set pyautogui._pyautogui_x11._display
to Xlib.display.Display(os.environ['DISPLAY'])
on Linux in order to sync up pyautogui
with the X11
virtual display after calling sbvirtualdisplay.Display(visible=True, size=(1366, 768), backend="xvfb", use_xauth=True).start()
. (For Xlib
, use import Xlib.display
after pip install python-xlib
.)