栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

FluentWait类型不是通用的;不能使用参数对其进行参数化 Selenium和Java导致FluentWait类错误

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

FluentWait类型不是通用的;不能使用参数对其进行参数化 Selenium和Java导致FluentWait类错误

您需要在等待中指定期望的条件,以下是修改后的代码,可以解决您的问题。

码:

import java.util.concurrent.TimeUnit;import org.junit.Test;import org.openqa.selenium.By;import org.openqa.selenium.NoSuchElementException;import org.openqa.selenium.WebDriver;import org.openqa.selenium.WebElement;import org.openqa.selenium.support.ui.ExpectedConditions;import org.openqa.selenium.support.ui.FluentWait;import org.openqa.selenium.support.ui.Wait;public class DummyClass{    WebDriver driver;    @Test    public void test()    {        Wait<WebDriver> wait = new FluentWait<WebDriver>(driver) .withTimeout(30, TimeUnit.SECONDS) .pollingEvery(5, TimeUnit.SECONDS) .ignoring(NoSuchElementException.class);        until(new Function<WebElement, Boolean>()         { public Boolean apply(WebElement element) {     return element.getText().endsWith("04"); } private void until(Function<WebElement, Boolean> function) {     driver.findElement(By.linkText("Sample Post2")); }        }    }}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/372564.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号