selenium自动化测试问题合集

(1)
webdriver打开chrome 显示: “您使用的是不受支持的命令行标记…”
原因:我当时的问题是由于下载的chromedriver 版本过低
解决方式:可以查看chrome的版本号,下载对应的chromedriver 版本:
http://npm.taobao.org/mirrors/chromedriver/
( 其他链接:
-chrome: http://chromedriver.storage.googleapis.com/index.html
-firfox :https://github.com/mozilla/geckodriver/releases/)
(2)
alert出现时1.无法用screentshot 2.如果未dismiss alert,后面的所有操作都会报错
解决方式:
1.目前webdriver没办法在alert出现时进行截图(后面研究下有没有别的方式可以绕过)
2.通过try ,except 这个error
selenium.common.exceptions.UnexpectedAlertPresentException

try:
….
except UnexpectedAlertPresentException:
driver.switch_to.alert.dismiss()

你可能感兴趣的:(Python,selenium)