selenium+java 獲得 cookie
阿新 • • 發佈:2018-11-16
public class CookieDemo { public static void main(String[] args){ //驅動配置 System.setProperty("webdriver.chrome.driver","D:\\driver\\chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.get("http://www.baidu.com"); Cookie c1 = new Cookie("name","name"); Cookie c2 = new Cookie("value","value"); driver.manage().addCookie(c1); driver.manage().addCookie(c2); //獲得 cookie Set<Cookie> coo =driver.manage().getCookies(); System.out.println(coo); //刪除所有cookie //driver.manage().deleteAllCookies(); driver.quit(); } }