1.自动化依赖以及谷歌驱动依赖
com.google.zxing core3.0.0 com.google.zxing javase3.0.0 org.seleniumhq.selenium selenium-java3.9.0
2.下载谷歌驱动http://chromedriver.storage.googleapis.com/index.html
3.直接上代码
System.setProperty("webdriver.chrome.driver", "D:\lixiao\tool\chromedriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setHeadless(false);
// 添加浏览器的伪装信息
chromeOptions.setExperimentalOption("useAutomationExtension", false);
chromeOptions.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
chromeOptions.addArguments("--disable-blink-features=AutomationControlled");
WebDriver driver = new ChromeDriver(chromeOptions);
try {
driver.get("https://passport.alibaba.com/icbu_login.htm?return_url=https%3A%2F%2Fdata.alibaba.com%2F");
Thread.sleep(1000);
driver.findElement(By.id("fm-login-id")).sendKeys(acount);
Thread.sleep(1000);
driver.findElement(By.id("fm-login-password")).sendKeys(password);
Thread.sleep(5000);
WebElement loginButton =driver.findElement(By.id("fm-login-submit"));
loginButton.click();
Thread.sleep(1000);
Set coo =driver.manage().getCookies();
for (Cookie cookie : coo) {
if(cookie.getName().equals("cookie2")){
System.out.println("登录成功"+cookie.getValue());
return cookie.getValue();
}
}
} catch (InterruptedException e) {
e.printStackTrace();
}finally {
driver.close();
driver.quit();
}



