Home > Software engineering >  Getting NoSuchElementException while trying Datepicker in jquery
Getting NoSuchElementException while trying Datepicker in jquery

Time:12-12

Tring to click on the input box, with script able to open the URL-https://jqueryui.com/datepicker/.In locator the id is available still getting No element foun. Tried with thread.sleep as well

when i am running the script getting exception

package SeleniumWebDriver;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;

public class HandlingCalender {

    public static void main(String[] args) throws InterruptedException {
        
        WebDriver driver =new ChromeDriver();

        driver.get("https://jqueryui.com/datepicker/");
        
        
        //driver.manage().window().maximize();
        
        Thread.sleep(1000);
        
        driver.findElement(By.id("datepicker")).click();
        

CodePudding user response:

Element you trying to access is inside an iframe.
So, to access it you need first to switch into that iframe, as following:

WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.class("demo-frame")));
wait.until(ExpectedConditions.elementToBeClickable(By.id("datepicker"))).click();
  • Related