解决Selenium WebDriver 加载页面时出现浏览器闪退
webdrive驱动edge浏览器打开网页后,会出现自动退出了情况时,大概率都是浏览器驱动和浏览器版本不一致的问题!以edge为例,我们可以通过点击浏览器的设置,找到关于Microsoft Edge查看当前的浏览器版本是否匹配webdriver的版本。
如果不匹配的话,可以去以下网址下载https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
如果还是不能解决selenium闪退,可以通过以下几行代码来解决此问题。
from selenium import webdriver from selenium.webdriver.edge.service import Service #设置浏览器参数 option = webdriver.EdgeOptions() option.add_experimental_option("detach", True) #打开浏览器驱动 s = Service(executable_path=r'C:\python\MicrosoftWebDriver.exe') #把浏览器参数传入到网页驱动 web = webdriver.Edge(options=option,service=s)
文章版权声明:除非注明,否则均为主机测评原创文章,转载或复制请以超链接形式并注明出处。
还没有评论,来说两句吧...