Hi ,
The situation is that I want to test login screen by using data driven method combined with Telerik Testing Framwork(WebAii).
Firstly, I can get all row data from excel file correctly. However, after i tried to use WebAii to work with data driven, in the first row of data fetched from Excel file, everything works fine but in the second row, all parameter from WebAii are turned into null. Please see my code below:
Note: 1. class RadControlsBaseTest inherits from class BaseTest.
2. class RadControlsBaseTest contains function which has attribute [TestInitialize()], [TestCleanup()], ...
From the code, the following WebAii parameters are turned to be null -> ActiveBrowser, Find, Manager.
Could you please advise?
Thanks in advance.
The situation is that I want to test login screen by using data driven method combined with Telerik Testing Framwork(WebAii).
Firstly, I can get all row data from excel file correctly. However, after i tried to use WebAii to work with data driven, in the first row of data fetched from Excel file, everything works fine but in the second row, all parameter from WebAii are turned into null. Please see my code below:
[TestClass]
public
class
Login : RadControlsBaseTest
{
[TestMethod()]
public
void
SettingUpBrowser()
{
SetUpBrowser(capiPage);
ActiveBrowser.WaitUntilReady();
}
[TestMethod()]
[DeploymentItem(
"Data\\Login.xlsx"
,
"Data"
)]
[DataSource(
"LoginDataSource"
)]
public
void
LoginTest()
{
if
(TestContext.DataRow !=
null
)
{
string
Username = TestContext.DataRow[
"Username"
].ToString();
string
Password = TestContext.DataRow[
"Password"
].ToString();
string
ExpectedResult = TestContext.DataRow[
"Expected Result"
].ToString();
string
ErrorText = TestContext.DataRow[
"Error Text"
].ToString();
Login(capiPage, Username, Password);
ActiveBrowser.WaitUntilReady();
if
(ExpectedResult.Equals(
"Fail"
))
{
//compare error text
}
else
if
(ExpectedResult.Equals(
"Pass"
))
{
//can navigate to main screen
}
}
}
protected
void
SetUpBrowser(PageControls page)
{
if
(Manager.ActiveBrowser ==
null
)
Manager.LaunchNewBrowser();
ActiveBrowser.ClearCache(BrowserCacheType.Cookies);
ActiveBrowser.ClearCache(BrowserCacheType.TempFilesCache);
ActiveBrowser.NavigateTo(
"/"
+ page.pageURL);
}
protected
void
Login(PageControls page,
string
username,
string
password)
{
//waiting for page to redirect to the login page
Manager.ActiveBrowser.WaitUntilReady();
if
(Manager.ActiveBrowser.ContainsText(
"Login.aspx"
) ==
true
)
{
HtmlInputText txtUserName = Find.ById<HtmlInputText>(
"loginControls_txtUserName"
);
AttributeUtils.chkNotNull(txtUserName,
"loginControls_txtUserName"
);
HtmlInputPassword txtPwd = Find.ById<HtmlInputPassword>(
"loginControls_txtPassword"
);
AttributeUtils.chkNotNull(txtPwd,
"loginControls_txtPassword"
);
HtmlInputSubmit btnLogin = Find.ById<HtmlInputSubmit>(
"loginControls_btnLogin"
);
AttributeUtils.chkNotNull(btnLogin,
"loginControls_btnLogin"
);
txtUserName.Text = username;
txtPwd.Text = password;
btnLogin.Click();
}
}
}
Note: 1. class RadControlsBaseTest inherits from class BaseTest.
2. class RadControlsBaseTest contains function which has attribute [TestInitialize()], [TestCleanup()], ...
From the code, the following WebAii parameters are turned to be null -> ActiveBrowser, Find, Manager.
Could you please advise?
Thanks in advance.