我在 python 中遇到问题。我的代码:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
chrome_options = webdriver.ChromeOptions()
chrome_options.binary_location = r'E:\Python\chromedriver\chrome.exe'
driver = webdriver.Chrome(options=chrome_options)
我安装了chrome和chrome驱动程序版本123.0.6312.122 运行代码时,我的浏览器已打开,但打开 0,5 到 1 然后关闭 请帮我。谢谢。 我希望运行代码时它不会自动关闭。我使用了 form time import sleep 并设置 sleep(50) 但我不想使用它。
尝试一下这段代码,我添加了分离选项
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option("detach", True)
chrome_options.binary_location = r'E:\Python\chromedriver\chrome.exe'
driver = webdriver.Chrome(options=chrome_options)