简体   繁体   中英

Selenium WebDriver Best Practice for Explicit Wait in the POM

Using the page object model where can I place my declaration of WebDriverWait so that it can be resused in POM? The below code is in the page class and the webelements are displayed in each page's own object repository. Here is my sample code

public bool IsAt()
{

    try
    {
        WebDriverWait wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(10));

        wait.Until(Driver => ObjectRepository.EnterButton.Displayed);

    }
    catch (Exception)
    {

    }


  return  ObjectRepository.EnterButton.Displayed;
}

如果要重新使用WebDriverWait对象,则可以将其放在POM级别的类中,也可以将驱动程序包装到一个DriverWrapper类中,该类维护其自己的WebDriverWait实例,在必要时公开WebDriverWait ,但允许与WebDriver同时实例化-特别是考虑到WebDriverWait直接依赖于WebDriver对象本身。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM