Exception in thread “main” org.openqa.selenium.NoSuchElementException: Unable to locate element: //*[@id='login-email']

后端 未结 4 627
情深已故
情深已故 2020-11-27 23:49

I had to re-test the xpath, Previously it was working fine, But now it gives me an error.

I tried with different locators as well, Like id

4条回答
  •  天涯浪人
    2020-11-28 00:27

    You are opening the URL and at the very next moment entering email-id. Before entering email-id, you need to check if the page is fully loaded. In this case, explicit wait will help you out-

    //opening the browser
    driver.get("https://staging.keela.co/login");
    
    //Explicit wait
    
    WebDriverWait wait = new WebDriverWait(WebDriverRefrence,20);
    WebElement email;
    email = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("login-email")));
    
    //logging
    driver.findElement(By.xpath("//*[@id='login-email']")).sendKeys("bandanakeela@yopmail.com");
    driver.findElement(By.xpath("//*[@id='login-password']")).sendKeys("keela");
    driver.findElement(By.xpath("//*[@id='login-form']/div[3]/div/button")).click();
    

提交回复
热议问题