[Solved] Error “no such element: Unable to locate element”


The email field is inside the frame. Before access any element in the frame, you have to switch. please try following code.

public static WebElement Email_Field(WebDriver driver) throws InterruptedException {

    WebElement element;

    (new WebDriverWait(driver, 30)).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("alibaba-login-box"));

    element = driver.findElement(By.xpath("//input[@id='fm-login-id']"));

    while (!isDisplayed(element)) {
        Thread.sleep(3000);
        System.out.println("Element is not visible yet");
    }

    return element;
}

solved Error “no such element: Unable to locate element”