使用Selenide执行两个测试用例时,TestNG测试失败。我是第一次接触Selenide

问题描述 投票:0回答:1

谁能帮帮我,好吗?我正在使用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();

    }

}
testng selenide
1个回答
1
投票

从你的控制台错误,你可以看到 Element not found

Element not found {By.id: txtUsername}

请检查是否存在可见元素->。

© www.soinside.com 2019 - 2024. All rights reserved.