Reputation: 244
I am creating a small test. In Code behind I have two classes. Pages, 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 .
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";
}
}
}
Upvotes: 0
Views: 1188
Reputation: 3235
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.
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() } }
Upvotes: 0