小编Pat*_*gee的帖子

使用Selenium PageObject设计模式的最佳方法是什么

我正在使用Selenium 2 Web Driver和C#.Net创建测试.在阅读了很多Selenium文档之后,我仍然不确定如何使用PageObject设计模式进行测试.

许多selenium示例仅在Java中显示,并且.Net的API绑定并不总是与人们认为的由于限制和某些语言设置的标准相似.

在.Net Selenium Web Driver中将PageObject设计模式与PageFactory一起使用的最佳方法是什么?

最终,我希望我的PageObjects处理更多功能,而不是使用PageObject IWebElements进行NUnit测试.

下面是我目前如何创建我的测试的示例.

public class LoginPage
{
    private IWebDriver webDriver;

    [FindsBy(How = How.Id, Using = "ctl00_ctl00_ctl00_insideForm_insideForm_content_txtPassword")]
    public IWebElement Password { get; set; }

    [FindsBy(How = How.Id, Using = "ctl00_ctl00_ctl00_insideForm_insideForm_content_cmdSubmit")]
    public IWebElement SubmitButton { get; set; }

    [FindsBy(How = How.Id, Using = "ctl00_ctl00_ctl00_insideForm_insideForm_content_txtUserName")]
    public IWebElement UserName { get; set; }

    public LoginPage() { }

    public LoginPage(IWebDriver webDriver)
    {
        this.webDriver = webDriver;


        if(!webDriver.Url.Contains("Login.aspx"))
        {
            throw new StaleElementReferenceException("This is not the login page");
        } …
Run Code Online (Sandbox Code Playgroud)

c# design-patterns webdriver pageobjects selenium-webdriver

29
推荐指数
1
解决办法
4万
查看次数

如何在UWP中获得单播,Dns和网关地址?

我试图在Windows IOT中找到单播,Dns和网关地址.通常我可以使用NetworkInterface.GetAllNetworkInterfaces()方法访问这些值 .

但在UWP中,缺少这种方法.

有没有替代方法来获得这些价值观?

.net c# iot windows-10-iot-core uwp

25
推荐指数
1
解决办法
2387
查看次数

Selenium Webdriver和PageFactory初始化List <WebElement>元素

我搜索了谷歌代码上托管的Selenium Webdriver APi文档.目前使用PageFactory来初始化我的Page对象,但是有问题初始化WebElement列表.

我需要的是一种初始化元素列表的方法,理想情况下是一个下拉选择框列表.

我查看了对@Findsby和@ByChained的API引用,但仍然无法找到初始化下拉选择框列表的最佳方法.我可以为每个人分配一个单独的WebElement并获取ID但是我想初始化List选择列表

目前我使用以下内容:

public class PageObject {

        @FindBy(id="element_id")
        private WebElement element;

        public getElement() {
          return element;
        }
}
Run Code Online (Sandbox Code Playgroud)

有什么方法可以使用类似于以下内容的东西:

public class PageObject {   

    @FindBys(className="selectItmes")
    private List<WebElement> selects;

    public List<WebElement> getSelects() {
      return selects;
    }  
}
Run Code Online (Sandbox Code Playgroud)

或者我必须为每个元素使用一个Web元素吗?:(

更新

任何人都知道如何使用PageFactory并初始化List元素; 使用FindsBy注释.我找不到任何办法这样做但是在selenium google docs网站上有谷歌问题说这已经在Java api绑定和版本2.12中得到修复,因为它在2.11中被误认为是......我仍然可以' t初始化列表.= /

webdriver selenium-webdriver

5
推荐指数
2
解决办法
3万
查看次数

如何查看日期是ruby中的最后一个月

我想检查一天是否是该月的最后一天,如果是,则函数返回true,否则返回false.

例如,如果我传入"Sun,2013年6月30日"的参数,则该函数将返回true,因为它是该月的最后一天,但是如果我传入参数"Mon,03 Jun 2013"函数是返回false.

如何使用Ruby实现这一目标.

ruby

2
推荐指数
2
解决办法
4390
查看次数