[英]driver.quit in selenium 3.0.2 firefox 50.1.0 firefox has stopped working
[英]python selenium driver.quit() can not quit firefox browser if firefox_profile setted
这个问题确实让我很困惑。 我正在使用python selenium做一些自动工作。 完成工作后,我需要关闭浏览器(我必须使用Firefox)。 我知道driver.close()
将关闭当前窗口,而driver.quit()
将关闭所有窗口并退出浏览器。 问题是:如果我使用python file.py来运行代码,则对我不起作用,但是如果我在python控制台中设置了驱动程序,则对我不起作用,这里的工作是说它只是关闭了我的网址,但是firefox浏览器无法退出。 以上所有测试均设置了firefox_profile。 更多,我发现如果我没有将firefox_profile设置为运行我的代码的第一种方法也可以正常工作。 我认为这可能是firefox_profile的错误。 希望有人拯救我的生活。 我的代码就像:
profile = webdriver.FirefoxProfile()
profile.set_preference('browser.download.folderList', 2) # custom location
profile.set_preference('browser.download.manager.showWhenStarting', False)
profile.set_preference('browser.download.dir', download_dir)
profile.set_preference(
'browser.helperApps.neverAsk.saveToDisk', 'application/octet-stream')
driver = webdriver.Firefox(
executable_path=gecko_dir, firefox_profile=profile)
driver.get(someurl)
driver.quit()# which will close my session, my url, my current window but not exit browser
我使用的版本:
当我们使用带有最新GeckoDriver v.0.18.0
和Mozilla Firefox 53.0
Selenium 3.5.0
,一旦在WebDriver
上调用quit()
,则由WebDriver
实例启动的浏览器窗口必定会被破坏(杀死)。实例。
因此,您看到的空白窗口可能是其他用户交互或悬空实例的结果。
您可以考虑以下步骤来启动干净的测试执行:
CCleaner
工具以清除以前执行中的所有剩余。 Test Execution
。 Test Environment
与其他User Interactions
隔离。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.