小编Ban*_*ngh的帖子

线程“main”中的异常org.openqa.selenium.NoSuchElementException:无法找到元素://*[@id='login-email']

我不得不重新测试xpath,以前它工作正常,但现在它给了我一个错误。

我也尝试过使用不同的定位器,例如idname。但仍然得到同样的错误。

package staging;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class login {

    public static void main (String[]args){
        System.setProperty("webdriver.gecko.driver","C:\\Program Files\\geckodriver.exe");
        WebDriver driver = new FirefoxDriver();

        //opening the browser
        driver.get("https://staging.keela.co/login");

        //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();       
 }
}
Run Code Online (Sandbox Code Playgroud)

java selenium xpath automation selenium-webdriver

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

automation ×1

java ×1

selenium ×1

selenium-webdriver ×1

xpath ×1