2
  1. Go to the Official Website of Jquery https://jqueryui.com/datepicker/

It's not allow be to click on input text even it's have unique id="datepicker" getting an error element not found Exception but when i runs locally by adding jquery date picker it works likes a charm. can somebody help me can't able to figure it out!

2) By using this url i can select anything but it not works with jquery official site as i mentioned above https://jqueryui.com/resources/demos/datepicker/default.html

Below is my actual code that is not getting work

System.setProperty("webdriver.chrome.driver","C:\\ProgramFiles\\chromedriver.exe");

      driver=new ChromeDriver();
      driver.manage().window().maximize();
      driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
      driver.get("https://jqueryui.com/datepicker/");
      Thread.sleep(5000);
      driver.findElement(By.id("datepicker")).click();
3
  • Change your URL to jqueryui.com/resources/demos/datepicker/default.html and then try Commented Aug 9, 2017 at 13:47
  • Why should i Change my URL Commented Aug 10, 2017 at 5:42
  • Because the datepicker is inside a IFrame and I am giving you the direct URL of IFrame so you can test your logic. Else use what you saw in @DebanjanB answer Commented Aug 10, 2017 at 6:07

1 Answer 1

1

The element with id="datepicker" is within a frame. So we have to switch to the intended frame first, then locate the element and then call the click() method as follows:

System.setProperty("webdriver.chrome.driver", "C:\\Utility\\BrowserDrivers\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.get("https://jqueryui.com/datepicker/");
driver.switchTo().frame(driver.findElement(By.xpath("//iframe[@class='demo-frame'][@src='/resources/demos/datepicker/default.html']")));
driver.findElement(By.id("datepicker")).click();
System.out.println("Datepicker Clicked");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.