[英]how to use selenium with fitnesse
I am creating a small test. 我正在创建一个小测试。 In Code behind I have two classes. 在后面的代码中,我有两个类。 Pages, LoginPage. 页面,LoginPage。 The first part is running. 第一部分正在运行。 I dont know how to integrate with second part. 我不知道如何与第二部分集成。 Currently I am able to open the browser. 目前,我可以打开浏览器。 Also I am trying to use the Page obect model pattern . 另外,我正在尝试使用Page obect模型模式。
Fitnesse code
!|import|
|TestFramework|
!|script|Pages|
|Goto||https://gmail.com|
|LoginPage|CheckRequiredElementsPresent|Pass|
Fixtures
public class Pages
{
string url;
private LoginPage loginPage;
public static void Goto(string url)
{
Browser.Goto(url);
}
}
public class LoginPage
{
static string PageTitle;
[FindsBy(How = How.Id, Using = "TextUsername")]
private static IWebElement username;
[FindsBy(How = How.Id, Using = "TextPassword")]
private static IWebElement password;
[FindsBy(How = How.Id, Using = "_ButtonLogin")]
private static IWebElement submit;
public string IsAtLoginPage()
{
return "";
}
public string CheckRequiredElementsPresent()
{
if (username != null && password != null && submit != null)
{
return "Pass";
}
return "Fail";
}
}
} }
You need to do something like below: 您需要执行以下操作:
!|import| |TestFramework| !|script|Pages| |Goto||https://gmail.com| |check Required Element|Pass|
You need to call your second class from your Pages class, please see the code changes & fitnesse fixture changes that I've made. 您需要从Pages类中调用第二个类,请参阅我所做的代码更改和fitnesse固定装置更改。
public class Pages { string url; private LoginPage loginPage; public static void Goto(string url) { Browser.Goto(url); } // This is what you need to do to refer method of second class. // This method will be called after Goto method in sequence. public boolean checkRequiredElement(){ return loginPage.CheckRequiredElementsPresent() } }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.