如何避免用户名和& Selenium webdriver中的密码提示提示(在验证代理时),chrome?
System.setProperty("webdriver.chrome.driver","C:/Selenium/Chrome/chromedriver.exe");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
Proxy proxy = new Proxy();
proxy.setHttpProxy("xx.xx.xxx.xx:yyyy");
proxy.setSslProxy("xx.xx.xxx.xx:yyy");
proxy.setSocksUsername("abcd");
proxy.setSocksPassword("efgh");
capabilities.setCapability("proxy", proxy);
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver = new ChromeDriver(capabilities);
driver.get("https://abcd:efgh@whatismyipaddress.com/");
答案 0 :(得分:1)
试试这个,
System.setProperty("webdriver.chrome.driver", "G:/Chrome/chromedriver.exe");
WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.get("http://abcd:efgh@whatismyipaddress.com/");