Selenium 为了硒化物的稳定性,如何使硒化物的测试稍微慢一点

Selenium 为了硒化物的稳定性,如何使硒化物的测试稍微慢一点,selenium,selenium-webdriver,selenium-chromedriver,selenide,Selenium,Selenium Webdriver,Selenium Chromedriver,Selenide,硒化物/硒专家 如何减缓硒化物测试以提高稳定性 我重写了Selenide使用的默认隐式等待,以尝试进行更可预测的测试。测试结果极不可预测:DOM元素的搜索不正确,但在调试模式下,它们总是被传递 测试驱动程序设置看起来像 @BeforeAll static void initDriver() { System.setProperty("webdriver...."); Configuration.browser = "chrome"; Configuration.timeo

硒化物/硒专家

如何减缓硒化物测试以提高稳定性

我重写了Selenide使用的默认隐式等待,以尝试进行更可预测的测试。测试结果极不可预测:DOM元素的搜索不正确,但在调试模式下,它们总是被传递

测试驱动程序设置看起来像

@BeforeAll
static void initDriver() {
    System.setProperty("webdriver....");
    Configuration.browser = "chrome";
    Configuration.timeout = 10_000L;//overriding
    Configuration.pageLoadStrategy = "normal";
    ...setting ChromeOptions
    driver = new ChromeDriver(options);

}

@Test
public void testLogin() {
    driver.get(url);
    setWebDriver(driver);
    // simple searching (byName) works fine
    $(By.name("username")).shouldBe(exist);
    $(By.name("username")).sendKeys("username");
    $(By.name("password")).shouldBe(exist);
    $(By.name("password")).sendKeys("password");
    //Any searching (byXpath) works unstable
    $(By.xpath("//*[@id=\"window\"]/div/div[3]/div[1]/div[1]/div/div[1]/input")).shouldBe(exist);
    $(By.xpath("//*[@id=\"window\"]/div/div[3]/div[1]/div[1]/div/div[1]/input")).sendKeys("PRODUCT");//bad pattern to re-run searching

}

很可能您需要添加一些WebDriverWait,以便在继续之前正确等待加载元素。你试过这个吗?我依赖于Selenide语法,应该是等待,但这对我们的项目来说是不够的。自从我们有$(selector).sendKeys(“ProductN”)以来,这个操作的速度非常快,有时甚至不能键入整个单词