User defined function terminates immediately
pdeepak4556 last edited by avan
I created a selenium project and defined a function and put the code into it.
Whenever I call the function the selenium code runs fine but after the code is executed the browser window quits automatically.
Is there a way to keep the browser window open forever until I manually close it?
avan last edited by
Here what I found online:
"Unless you explicitly tell Selenium to keep the browser open, it will close as soon as all commands are completed.
If you only want to leave it open for a certain amount of time, specify a wait time. (Ex: time.sleep(10) )
If you want to leave the browser open until you manually close it, you will need to enable chrome options when you create your webdriver.
from selenium.webdriver.chrome.options import Options
chrome_options = Options() chrome_options.add_experimental_option("detach", True)
driver = webdriver.Chrome(options=chrome_options)
Hopefully all of the syntax is right, I did this on mobile. If it's wrong, this should give you enough to effectively Google the solution."
I hope this helps. I have never worked with selenium so this is the best I can do.