1

When I am launching below website, not able to handle the below cookies page. I want to click on "Allow Cookies" button on that frame. Please help me on this.

driver = new FirefoxDriver();
driver.get("http://www.ns.nl/en/travellers/home");
driver.findElement(By.partialLinkText("Netherl ")).click();
3
  • It's not really clear what you're trying to achieve. What is the 'Allow cookies' button, and what does the rest of your page look like?
    – Knelis
    Jan 27, 2015 at 10:38
  • If you run above code, it webpage gets launched with the coockies page. Screenshot of this is shared on below path. (imgur.com/jJ8Jb6Z) Because of that I am not able to proceed. Sorry for the confusion, please let me know if you need more information. Thanks!
    – Durgesh
    Jan 27, 2015 at 10:47
  • In your code you are trying to click Netherl. Where is that? If you are trying to click Allow Cookies click it by cssSelector . .button.allow Jan 27, 2015 at 12:06

2 Answers 2

1

Use following:

driver.findElement(By.xpath("//a[@class='button allow']/span[text()='Allow cookies']")).click();

it will click on Allow cookies button.

1
  • Yes, its working. Thanks. Also I tried with below command. {driver.findElement(By.cssSelector("a.button.allow > span")).click();}
    – Durgesh
    Feb 12, 2015 at 3:17
0

If you click the 'Accept' button, two cookies are set: ns-cookie-toestemming with value ja, and ns-cookie-toestemming-datum with a URL-encoded value of the time, like this 27-1-2015%2012%3A3 (encoded from 27-1-2015 12:3).

According to the Selenium documentation you should be able to set cookies for the user. If you set these cookies, the user should not get the cookie consent popup.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.