Closed gabrielsim closed 1 month ago
Hi @mdmintz ,
I have a use case where it requires using uc_click on the form submit button as the driver is detectable after submission. However, this form takes me to a page with an alert to be dismissed before the rest of the page loads.
Is there a solution?
Here is an example:
from seleniumbase import SB
with SB(uc=True) as sb:
sb.open("https://form-page.tiiny.site")
# Does not work - Code is stuck here as it waits for page to complete loading
sb.uc_click("input", timeout=2, reconnect_time=2)
# Works - Does not wait for page to complete loading, but I need uc_click
# sb.click("input")
sb.dismiss_alert()
print(sb.get_page_source())
There is a solution. The code below works on seleniumbase
4.26.4
(or newer) after installing pyautogui
:
import pyautogui
from seleniumbase import SB
with SB(uc=True) as sb:
sb.open("https://form-page.tiiny.site")
sb.uc_click("input", timeout=2, reconnect_time="disconnect")
sb.sleep(1)
pyautogui.press("\n")
sb.sleep(1)
sb.reconnect()
print(sb.get_page_source())
@mdmintz Thanks, this works! Did not know that reconnect_time="disconnect"
existed.
Do you also have a solution if I need this with headless seleniumbase?
For non UC Mode headless seleniumbase, you wouldn't need pyautogui at all. But for maximum stealth in UC Mode, use a headed browser.
Got it, thank you for the help!
Originally posted by @mdmintz in https://github.com/seleniumbase/SeleniumBase/issues/2662#issuecomment-2038876243