I\'m trying to add cookies to a link before I open it with webdriver but it keeps giving me this error:
org.openqa.selenium.UnableToSetCookieException
First navigate to URL and then try to add cookies, try below code:
System.setProperty("webdriver.edge.driver","C:\\Program Files\\Latest Webdriver\\MicrosoftWebDrive.exe" );
EdgeDriver = new EdgeDriver();
Thread.sleep(2000);
Cookie cookie = new Cookie("Testing", "11111");
EdgeDriver.manage().addCookie(cookie);
EdgeDriver.get("https://www.google.ca/?gws_rd=ssl"); // The link is an example
Replace your code with this :
System.setProperty("webdriver.edge.driver","C:\\Program Files\\Latest Webdriver\\MicrosoftWebDrive.exe" );
EdgeDriver = new EdgeDriver();
Thread.sleep(2000);
EdgeDriver.get("https://www.google.ca/?gws_rd=ssl"); // The link is an example
Cookie cookie = new Cookie("Testing", "11111");
EdgeDriver.manage().addCookie(cookie);