'org.openqa.selenium.ElementNotInteractableException: Element is not reachable by keyboard: while sending text to FirstName field in Facebook

The error is :

Exception in thread "main" org.openqa.selenium.ElementNotInteractableException: Element is not reachable by keyboard

The code is:

System.setProperty("webdriver.gecko.driver","//Users//rozali//Documents//Selenium//geckodriver");
        WebDriver driver = new FirefoxDriver();
        driver.get("http://www.facebook.com");
        driver.manage().window().maximize();

        //entering first name
        driver.findElement(By.id("u_0_b")).click();
        driver.findElement(By.id("u_0_b")).sendKeys("testing it ");
        
        //DOB
        Select sel1 = new Select(driver.findElement(By.xpath(".//*[@id='month']")));
        sel1.selectByIndex(4);
        
        Select sel2 = new Select(driver.findElement(By.xpath(".//*[@id='day']")));
        sel2.selectByValue("6");
        
        Select sel3 = new Select(driver.findElement(By.xpath(".//*[@id='year']")));
        sel3.selectByValue("2013");
        
        //clicking sign up
        driver.findElement(By.id("u_0_t")).click();


Solution 1:[1]

You can try this code :

public class Rozmeen{

    static WebDriver driver;
    static WebDriverWait wait;

    public static void main(String[] args) throws InterruptedException {
            System.setProperty("webdriver.gecko.driver", "F:\\Automation\\geckodriver.exe");
            driver = new FirefoxDriver();
            driver.manage().window().maximize();
            WebDriverWait wait = new WebDriverWait(driver, 40);
            driver.get("http://www.facebook.com");

            //entering first name
            wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.id("pagelet_bluebar"))));
            driver.findElement(By.name("firstname")).sendKeys("testing it ");

            //DOB
            selectFromDropDown(driver.findElement(By.name("birthday_day")), "4");
            selectFromDropDown(driver.findElement(By.name("birthday_month")), "Jun");
            selectFromDropDown(driver.findElement(By.name("birthday_year")), "2013");

            //clicking sign up
            wait.until(ExpectedConditions.elementToBeClickable(driver.findElement(By.name("websubmit"))));
            driver.findElement(By.name("websubmit")).click();
        }



        public static void selectFromDropDown(WebElement element , String Visibletext){
            Select select = new Select(element);
            select.selectByVisibleText(Visibletext);
        }
}  

try out this code and let me know the status.

Solution 2:[2]

In one of the use cases I had the same issue:

Exception in thread "main" org.openqa.selenium.ElementNotInteractableException: Element <div id="search"> is not reachable by keyboard

using id for identifying an element before sending keys. Something like:

driver.findElement(By.id("search")).sendKeys("...");

After testing I changed to CSS Selector and it solved the issue:

driver.findElement(By.cssSelector("#search > input:nth-child(2)")).sendKeys("...");

So, I highly recommend to use different methods to interact with the elements, because something else can save your time solving problems.

Solution 3:[3]

I got a similar error on a button when the click() operation was performed:

org.openqa.selenium.ElementNotInteractableException Exception

As mentioned by DebanjanB in his answer, the element was not reachable by keyboard. To solve this, I replaced click() with sendKeys(Keys.ENTER), and the button got clicked.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 cruisepandey
Solution 2
Solution 3 The Amateur Coder