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

后端 未结 4 626
情深已故
情深已故 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:03

    Try this below code.

    Note: If id attribute is available then you should use id and for xpath try to use relative xpath.

    I have used explicit wait method, so your driver may able to find the next webelement, after page is fully loaded.

    driver.get("https://staging.keela.co/login");
    driver.manage().window().maximize();
    
    //Explicit wait for 60 seconds, to find the webelement. You can increase or decrease the time as per your specification.        
    new WebDriverWait(driver, 60).until(ExpectedConditions.elementToBeClickable(driver.findElement(By.id("login-email"))));
    driver.findElement(By.id("login-email")).sendKeys("bandanakeela@yopmail.com");
    driver.findElement(By.id("login-password")).sendKeys("keela");
    driver.findElement(By.xpath("//button[@type='submit'][text()='Log in']")).click();
    

提交回复
热议问题