Selenium webdriver 失败,恕不另行通知 ssl 错误

Selenuim webdriver fails without notice for ssl error

我正在使用 selenuim webdriver 获取具有 https 方案的页面。如果我使用 chrome 转到页面,我会得到 'privacy error' 并且响应为空。 如果我使用 webdriver 获取页面,webdriver 停留在它所在的最后一页。我如何检测 webdriver 没有移动到新页面?

我考虑过检查 driver.current_url 是否与我想要的 url 相同,但感觉不是正确的解决方案。

代码:

from selenium import webdriver

driver = webdriver.PhantomJS()
driver.get('http://doman.com/1.html')  # this return 200 status and content
driver.get('https://domain2.com/2.html') # this return the privacy error 
# so the driver is still at the first url

阅读后我想我找到了解决方案support desired_capabilities: acceptSslCerts=True

from selenium import webdriver

service_args = ['--ignore-ssl-errors=true']
driver = webdriver.PhantomJS(service_args=service_args)
driver.get('http://doman.com/1.html')
driver.get('https://domain2.com/2.html')  # now it returns 404 as it should