You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on automating a form submission process using SeleniumBase with uc=True. After submitting the form with the required values, the driver unexpectedly closes with the error: invalid session id.
I tried using libraries like requests or requests_html, but the website's HTML contains a message: Enable JavaScript and cookies to continue, making these libraries unsuitable. Hence, I need Selenium to handle this task.
When I say the driver closes, I mean it closes approximately 2 seconds after submitting the form. It can still execute the next Python statement (a return in my case), but the driver terminates unexpectedly without any explicit command to close it.
My code
fromseleniumbaseimportDriverdriver=Driver(uc=True)
driver.get("URL")
driver.wait_for_element("#btnContinue")
# Fill the formdriver.execute_script("arguments[0].value = arguments[1];", driver.find_element("css selector"), data1)
driver.execute_script("arguments[0].value = arguments[1];", driver.find_element("css selector"), data2)
# I also tried using `driver.submit("#btnContinue")`, but it fails after 7 seconds,# stating that the button cannot be clicked. The button is disabled for 30 seconds# on the website, but `driver.find_element("#btnContinue").submit()` bypasses this restriction.driver.find_element("#btnContinue").submit() # Browser closes 2 seconds after this line# This code is executed tooreturndriver.find_element("css selector").get_attribute("href")
Does anyone know how I can prevent the driver from closing unexpectedly after submitting the form? Any suggestions or insights would be greatly appreciated!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Problem Summary
I'm working on automating a form submission process using SeleniumBase with
uc=True
. After submitting the form with the required values, the driver unexpectedly closes with the error: invalid session id.I tried using libraries like requests or requests_html, but the website's HTML contains a message: Enable JavaScript and cookies to continue, making these libraries unsuitable. Hence, I need Selenium to handle this task.
When I say the driver closes, I mean it closes approximately 2 seconds after submitting the form. It can still execute the next Python statement (a return in my case), but the driver terminates unexpectedly without any explicit command to close it.
My code
Does anyone know how I can prevent the driver from closing unexpectedly after submitting the form? Any suggestions or insights would be greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions