Testing Framework with data driven on web UI testing

2 posts, 0 answers
  1. David
    David avatar
    1 posts
    Member since:
    May 2012

    Posted 27 Nov 2012 Link to this post

    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.
  2. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 29 Nov 2012 Link to this post

    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
Back to Top