这是我使用的代码。我需要浏览器会话保持活跃10分钟。
chrome_options = webdriver.ChromeOptions()
chrome_options.binary_location = os.environ.get("GOOGLE_CHROME_BIN")
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-dev-shm-usage")
chrome_options.add_argument("--no-sandbox")
s = Service(executable_path=os.environ.get("CHROMEDRIVER_PATH"))
driver = webdriver.Chrome(service=s, options=chrome_options)
driver.get(URL)
button = driver.find_element(by=By.XPATH,value='XPATH')
button.click()
time.sleep(600)
driver.quit()
这是我在日志中看到的
2022-05-16T15:06:47.277256+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2022-05-16T15:06:48.362371+00:00 heroku[web.1]: Process exited with status 137
2022-05-16T15:06:47.953605+00:00 heroku[web.1]: Stopping process with SIGKILL
2022-05-16T15:06:48.465543+00:00 heroku[web.1]: State changed from starting to crashed
1条答案
按热度按时间vhipe2zx1#
我发现这很有用,也许对你有帮助。
selenium保持浏览器打开
如何保持webdriver标签页打开
** selenium 开放检查**
从selenium导入webdriver
来源:https://www.codegrepper.com/code-examples/python/selenium+keep+browser+open
谢谢祝您愉快。