Can i reuse the same(single)script with different data?

5 posts, 0 answers
  1. Devangi
    Devangi avatar
    2 posts
    Member since:
    May 2011

    Posted 19 May 2011 Link to this post

    Let say i have a login script. If i go with appraoch of data driven then i have to create 5 login script if i have 5 Users.

    Is there any way where we can have only login script in entire project and just pass different user's login credentials when required?
  2. Artem
    Artem avatar
    25 posts
    Member since:
    Jul 2010

    Posted 20 May 2011 Link to this post

    Hi, you could add coded step Login (something like my example) and uncheck it but call this method from your main script with different parameters

    [CodedStep(@"Login", RequiresSilverlight = true)]
            public void Login(string login, string password)
            {
                Pages.xxx.Login1UserNameText.Text = login;
                Pages.xxx.Login1PasswordPassword.Text = password;
                Pages.xxx.Login1LoginLink.Click();
            }
  3. Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 24 May 2011 Link to this post

    Hi,

    In addition you can also go with a data-driven approach following the steps bellow:

    1. Record the steps that are related to the login form.
    2. Create a local data that has two columns one for the users and one for the passwords. Fill the data in them.
    3. Bind step that set user name to that user field
    4. Bind step that set password to that password field

    Now this test will be executed for each user and pass from the data table.

    You can find this described in details here. For further assistance, do not hesitate to contact us.

    Best wishes,
    Dobry Zranchev
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  4. Shashi
    Shashi avatar
    25 posts
    Member since:
    Feb 2011

    Posted 25 May 2011 Link to this post

    Artem,

    Can you share an example of a test that uses that coded step?  I would like to know how you pass information to that method.  

    Thanks,
    Shashi
  5. Artem
    Artem avatar
    25 posts
    Member since:
    Jul 2010

    Posted 26 May 2011 Link to this post

    [CodedStep(@"MainTest", RequiresSilverlight = true)]
            public void MainTest()
            {
                  Manager.ActiveBrowser.NaviagteTo(URL);
                  Login("User", "Password")
            }
     
    [CodedStep(@"Login", RequiresSilverlight = true)]
            public void Login(string login, string password)
            {
                Pages.xxx.Login1UserNameText.Text = login;
                Pages.xxx.Login1PasswordPassword.Text = password;
                Pages.xxx.Login1LoginLink.Click();
            }


    Step Login should be unchecked in steps list.
Back to Top
  Cast Your Vote at DevPro Connections! Cast Your Vote at  Win IT Pro Connections!