我正在创建一个小测试。在Code背后,我有两个类。页面,登录页面。 第一部分正在运行。我不知道如何与第二部分整合。目前我可以打开浏览器。此外,我正在尝试使用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";
}
}
}
答案 0 :(得分:0)
您需要执行以下操作:
!|import| |TestFramework| !|script|Pages| |Goto||https://gmail.com| |check Required Element|Pass|
您需要在Pages类中调用第二个类,请参阅代码更改& fitnesse fixture改变了我所做的。
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() } }