处理使用Selenium浏览器认证

处理使用Selenium浏览器认证

问题描述:

有谁知道怎样处理使用硒或自动化过程中任何其他工具浏览器验证?

Does anyone know about handling Browser Authentication using Selenium or any other tool during automation?

这答案是过时的。时下的webdriver支持验证!见How办理认证弹出硒的webdriver

EDIT in 2015:

This answer is outdated. WebDriver nowadays supports authentication! See How to handle authentication popup with Selenium Webdriver

这不是由硒处理得很好。

This is not handled very well by Selenium.

您可以尝试使用的http://用户名:password@example.com/yourpage

而不仅仅是 http://example.com/yourpage

不过,据我所知,火狐仍然会弹出一个浏览器对话框,要求确认。

However, as far as I know, Firefox will still pop up a browser dialog requesting a confirmation.

您可以尝试机器人如果你使用的是Java(或任何类似的工具,如 AutoIt的)。

You can try Robot if you're using Java (or any similar tool like AutoIt).

您可以使用driver.manage().addCookie()$c$c>如果你使用的webdriver。

You could use driver.manage().addCookie() if you're using WebDriver.

或自定义的FirefoxProfile一个已经通过认证一次。

Or a custom FirefoxProfile that has already passed the authentication once.