Issue
I have this code:
System.setProperty("webdriver.gecko.driver", "D:\\chromedriver");
WebDriver webDriver = new ChromeDriver();
webDriver.get("https://example.com");
Thread.sleep(3000);
Cookie cookie = new Cookie.Builder("dsdsdsds", "dsdsds").path("/").sameSite("None").expiresOn(new Date()).isSecure(true).build();
webDriver.manage().deleteAllCookies();
webDriver.manage().getCookies().add(cookie);
webDriver.manage().getCookies().add(new Cookie("__Secure-access_token", accessToken));
webDriver.manage().getCookies().add(new Cookie("__Secure-id_token", secIdToken));
webDriver.manage().getCookies().add(new Cookie("__Secure-id_hint", idHint));
webDriver.manage().getCookies().add(new Cookie("a12l-csrf-prod", csrfToken));
webDriver.manage().getCookies().add(new Cookie("id_token", idToken));
webDriver.navigate().refresh();
webDriver.manage().getCookies().forEach(System.out::println);
However, after reloading, the standard page cookies are rendered, but my custom ones are not. What to do?
Solution
You are adding the cookies to the Set
returned from getCookies()
, you need to add it to the WebDriver
webDriver.manage().addCookie(new Cookie("__Secure-access_token", accessToken));
Answered By - Guy
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.