谁能帮帮我,好吗?我正在使用TestNG和Java的Selenide框架工作,我的测试越来越失败,而运行多个@Test注释的单一@Test它是工作的控制台错误日蚀
public class LoginTest {
@BeforeTest
public void beforeTest() {
System.setProperty("webdriver.chrome.driver", ".//src//test//resources//Drivers//chromedriver.exe");
Configuration.browser = "chrome";
Configuration.timeout = 5000;
open("https://opensource-demo.orangehrmlive.com/");
}
@Test
public void Test1() {
$(By.id("txtUsername")).setValue("Admin");
$(By.id("txtPassword")).setValue("admin123");
$(By.id("btnLogin")).click();
$(By.id("welcome")).shouldHave(text("Welcome Admin"));
}
@Test
public void Test2() {
$(By.id("txtUsername")).setValue("Admin");
$(By.id("txtPassword")).setValue("admin123");
$(By.id("btnLogin")).click();
$(By.id("welcome")).shouldHave(text("Welcome Admin"));
$(By.id("welcome")).click();
$(By.xpath("//a[@href='/index.php/auth/logout']")).click();
}
}
从你的控制台错误,你可以看到 Element not found
Element not found {By.id: txtUsername}
请检查是否存在可见元素->。