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

如何在PageObjectModel的PageFactory中添加显式等待?

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

如何在PageObjectModel的PageFactory中添加显式等待?

PageObjectModel中* 使用 PageFactory时
,如果您希望该元素通过某些Javascript加载并且可能已经不存在于页面中,则可以对普通的定位器工厂使用
Explicit Wait 支持,如下所示:

* __

  • 代码块:
        package com.pol.zoho.PageObjects;    import org.openqa.selenium.By;    import org.openqa.selenium.WebDriver;    import org.openqa.selenium.WebElement;    import org.openqa.selenium.support.FindBy;    import org.openqa.selenium.support.PageFactory;    import org.openqa.selenium.support.ui.ExpectedConditions;    import org.openqa.selenium.support.ui.WebDriverWait;    public class ZohoLoginPage {        WebDriver driver;        public ZohoLoginPage(WebDriver driver)        { PageFactory.initElements(driver, this);        }        @FindBy(xpath=".//*[@id='lid']")        public WebElement email;        @FindBy(xpath=".//*[@id='pwd']")        public WebElement password;        @FindBy(xpath="//*[@id='signin_submit']")        public WebElement signin;        public void doLogin(String username,String userpassword)        { WebElement element = new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(ZohoLoginPage.getWebElement())); email.sendKeys(username); password.sendKeys(userpassword); signin.click();        }        public WebElement getWebElement()        { return email;        }    }

您可以在如何对PageFactory字段和PageObject模式使用显式等待中找到详细的讨论。



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

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

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