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

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

4 Answers 105 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Devangi
Top achievements
Rank 1
Devangi asked on 19 May 2011, 07:34 AM
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?

4 Answers, 1 is accepted

Sort by
0
Artem
Top achievements
Rank 1
answered on 20 May 2011, 10:49 AM
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();
        }
0
Dobry Zranchev
Telerik team
answered on 24 May 2011, 08:26 AM
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 >>

0
Shashi
Top achievements
Rank 1
answered on 25 May 2011, 10:24 PM
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
0
Artem
Top achievements
Rank 1
answered on 26 May 2011, 11:44 AM
[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.
Tags
General Discussions
Asked by
Devangi
Top achievements
Rank 1
Answers by
Artem
Top achievements
Rank 1
Dobry Zranchev
Telerik team
Shashi
Top achievements
Rank 1
Share this question
or