我不得不重新测试xpath
,以前它工作正常,但现在它给了我一个错误。线程“主”异常org.openqa.selenium.NoSuchElementException:无法找到元素:// * [@ id ='login-email']
我试过不同的定位器,像id
,name
。但仍然得到相同的错误。
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("[email protected]");
driver.findElement(By.xpath("//*[@id='login-password']")).sendKeys("keela");
driver.findElement(By.xpath("//*[@id='login-form']/div[3]/div/button")).click();
}
}
你确定的ID是'登录,email'?可能是一个错字..你有测试页面的源代码截图吗? – jaredgilmore
好的我已经发布了它可以在左侧看到它(顶部)@jaredgilmore –
对不起,我的意思是你正在测试的网页的源代码,而不是测试。 – jaredgilmore