【发布时间】:2017-12-09 23:36:04
【问题描述】:
我正在尝试自动化 Web 应用程序 selenium 2.0 [webdriver+java]。Web 应用程序当前部署在我们本地网络上的 UAT 服务器中。我的测试用例正在执行,但我必须手动输入代理身份验证在测试执行开始时我的 Chrome 实例的详细信息。我已经尝试了堆栈溢出提供的所有解决方案,但仍然会弹出身份验证消息。
这是我在驱动程序初始化过程中使用的代码
包 com.misyn.ess.ui;
import java.util.Arrays;
import org.openqa.selenium.Proxy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.DesiredCapabilities;
/**
*
* @author User
*/
public class DriverClass {
private String baseUrl;
private String driverPath;
private String driverName;
private static WebDriver driver;
private static DriverClass driverClass;
private DriverClass() {
try {
baseUrl = "http://192.168.0.10:8282/ess";
driverPath = "E:\\Work_Folder\\SelTools\\chromedriver.exe";
driverName = "webdriver.chrome.driver";
//Set the location of the ChromeDriver
System.setProperty(driverName, driverPath);
//Create a new desired capability
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
// Create a new proxy object and set the proxy
Proxy proxy = new Proxy();
proxy.setHttpProxy("192.168.0.200:3128");
proxy.setSocksUsername("avishka");
proxy.setSocksPassword("12345678");
//Add the proxy to our capabilities
capabilities.setCapability("proxy", proxy);
//Start a new ChromeDriver using the capabilities object we created and added the proxy to
driver = new ChromeDriver(capabilities);
//Navigation to a url and a look at the traffic logged in fiddler
driver.navigate().to(baseUrl);
// System.setProperty(driverName, driverPath);
// driver = new ChromeDriver();
// driver.get(baseUrl);
} catch (Exception e) {
e.printStackTrace();
}
}
}
谁能给我一个解决方案,如何从应用程序本身提供此代理用户名和密码,而不是在弹出窗口中手动输入详细信息(身份验证),任何帮助将不胜感激。谢谢
当前回答的只是为了
从 Selenium 3.4 开始,它仍处于测试阶段 目前仅针对 InternetExplorerDriver 进行实施
我使用 selenium 3.0 和 Google Chrome 作为我的网络浏览器。
【问题讨论】:
-
您使用的是哪个 chrome 版本?
-
版本 59.0.3071.115(官方版本)(64 位)@santhoshkumar
-
那我觉得我们需要使用AUTOIT工具
-
什么是AUTOIT工具
-
任何代码或教程如何使用它进行代理身份验证@santhoshkumar
标签: java selenium selenium-webdriver webdriver qa