Answer the question
In order to leave comments, you need to log in
How to use cookies in selenium?
You need to go to the site with native cookies (already authorized or, for example, already with a filled basket in the online store)
What I tried:
1)
System.setProperty("webdriver.chrome.driver","E:\\Roma\\prog\\Java\\project\\yandex\\driver\\chromedriver.exe");
ChromeOptions opt = new ChromeOptions();
opt.setBinary("C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe");
opt.addArguments("--user-data-dir=C:\\Users\\Roma\\AppData\\Local\\Google\\Chrome\\User Data");
ChromeDriver driver=new ChromeDriver(opt);
driver.get("https://site.ru/checkout");
Cookie cookie = new Cookie.Builder("name", "value")
.domain(".mydomain.com")
.expiresOn(new Date(2015, 10, 28))
.isHttpOnly(true)
.isSecure(false)
.path("/mypath")
.build();
driver.manage().addCookie(cookie);
Answer the question
In order to leave comments, you need to log in
"open selenium browser, log in there"for me, this solution is much better than the two options above.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question