Home > Mobile >  Element Clickable in Java Selenium
Element Clickable in Java Selenium

Time:09-12

I'm trying to click on Calendar but everytime I try to click on the calendar the error pop up as "element click intercepted: Element is not clickable at point (293, 1317)

<input type="text" name="form_fields[travel_comp_date]" id="form-field-travel_comp_date"
 placeholder="Date of travel"
pattern="[0-9]{4}-[0-9]{2}-[0-9]{2}" readonly="readonly">

Here's my code:

WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5));
    wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@name='form_fields[travel_comp_date]']")));
    driver.findElement(By.xpath("//input[@name='form_fields[travel_comp_date]']")).click();

Can someone please help me correcting this.

CodePudding user response:

The element you are trying to access is out of the initially presented view port.
In order to click it you first need to scroll the page to bring that element into the visible view port and only after that you will be able to click on it.
Please try this:

JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("window.scrollTo(0, document.body.scrollHeight)");

Or this

JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("window.scrollBy(0,600)");

After that try performing your code

  • Related