Home > Net >  ElementNotInteractableException: element not interactable in Selenium Java
ElementNotInteractableException: element not interactable in Selenium Java

Time:12-27

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

public class E2E {

    public static void main(String[] args) throws InterruptedException {
    System.setProperty("webdriver.chrome.driver",  "D:\\Selenium\\chromedriver.exe");
    WebDriver driver = new ChromeDriver();
    driver.get("https://www.flygofirst.com/");

    driver.findElement(By.xpath("//span[@id='onewaymodal-id']")).click();
    Thread.sleep(25000);
    driver.findElement(By.xpath("//div[@id = 'oneWaybd']//div[@class ='fromTo']/div[1]")).sendKeys("Ch");

    

    
    

    

    }

}

I Tried to SendKeys in the From Text Box i was getting Element not Intractable.

And I provided Waiting time so that all the web elements will load. After that also i got the same exception Element not Intractable.

Can anyone help me with this

CodePudding user response:

You have to modify the locator, try this one, its working:

// to handle the Accept Cookies button
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(15));
wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("#cookie-btn"))).click();
        
driver.findElement(By.xpath("//span[@id='onewaymodal-id']")).click();
Thread.sleep(1000);

// modified the below locator
driver.findElement(By.xpath("(.//div[@class='fromTo']//input[@id='roundTripbdFromView'])[2]")).sendKeys("ch"); 

I answered your previous question also, check that, if it works, mark that as the answer.

  • Related