问题
I am looking to keep the browser window open even after test execution. I would like to keep it open indefinitely. As of now , as a work around I am just using "Sleep" to keep the window from closing.
Any help would be much appreciated. Thank you !
回答1:
Simple - do not call Close Browser
at the end.
回答2:
Ideally, the WebDriver service should stop once your script ends due to this code.
However if you want Chrome and ChromeDriver to stay open afterwards, you can add the experimental option detach
when initializing the chromedriver.
Through Selenium-Python client you can:
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_experimental_option("detach", True)
driver = webdriver.Chrome(chrome_options=options, executable_path=r'C:\WebDrivers\chromedriver.exe')
driver.get('https://www.google.com/')
回答3:
In a previous Stack Overflow question about connecting to the Chrome remote-debugging-port I provided an example for connecting to a running chrome instance using it's Dev Port.
This will functionally do what you want and as such may be an alternative to no closing as suggested by @Todor and @Bryan.
来源:https://stackoverflow.com/questions/55186282/is-there-a-way-to-keep-the-browser-window-open-after-the-test-execution-in-robot