What's the best way to use Selenium PageObject Design Pattern

后端 未结 3 546
长情又很酷
长情又很酷 2020-12-12 16:34

I\'m creating tests using Selenium 2 Web Driver with C#.Net. After reading through a lot of the Selenium documentation, I am left still feeling unsure on how to go about tes

3条回答
  •  情书的邮戳
    2020-12-12 17:08

    Use PageFactory.InitElements(_driver, this); on the constructor of your base page class:

    public class Page
    {
        public IWebDriver _driver;
    
        public Page(IWebDriver driver)
        {
            this._driver = driver;
            PageFactory.InitElements(_driver, this);
        }
    }
    

    Please see the PageFactory documentation

提交回复
热议问题