我一直在努力解决这个问题。所以我在pytest中使用参数化来进行用Python编写的跨浏览器测试。我能够启动所有3个实例但在测试结束时只有Chrome实例关闭但Safari和Firefox保持打开状态。这是我的剧本:
@pytest.mark.parametrize("browser", [
("chrome"),
("firefox"),
("safari")]
)
def test_eval(browser):
print browser
if browser == "chrome":
driver = webdriver.Chrome()
elif browser == "firefox":
caps = DesiredCapabilities.FIREFOX
caps["marionette"] = True
caps["binary"] = "/Applications/Firefox.app/Contents/MacOS/firefox-bin"
driver = webdriver.Firefox(capabilities=caps)
elif browser == "safari":
os.environ["SELENIUM_SERVER_JAR"] = "selenium-server-standalone-3.0.0-beta2.jar"
driver = webdriver.Safari()
driver.get("https://www.google.com")
driver.quit()
提前感谢您的帮助!
答案 0 :(得分:1)
这可能有所帮助,Difference between webdriver.Dispose(), .Close() and .Quit()
他们建议将driver.close()用于那些不是chrome
的