This is a migrated thread and some comments may be shown as answers.

Testing Framework with data driven on web UI testing

1 Answer 73 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 27 Nov 2012, 07:31 AM
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:

[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.

1 Answer, 1 is accepted

Sort by
0
Cody
Telerik team
answered on 30 Nov 2012, 04:41 AM
Hello David,

This is a duplicate of your support ticket 633894 in which I already responded requesting for additional information. Let's continue this problem on your support ticket.

Kind regards,
Cody
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
David
Top achievements
Rank 1
Answers by
Cody
Telerik team
Share this question
or