1

I have a Test case in which I logs into the application, then on the Home page there are 7 links and I need to perform testing for all these 7 links by clicking each link and performing a series of actions for each link. I can do this sequentially very easy by clicking on first link then performing all actions related to that link than came back again to the home page and then again click on 2nd link and so on...

But the problem is that testing for each link takes around 10-20 minutes and I want to perform it parallely. and I also can't login same user on two browser instances (Logging the same user again terminates the older session).

So the only way to perform it paralelly is to initialize a Webdriver object, login through it and go to home page, Then create 7 copies of this Webdriver object(say driver1, driver2, driver 3...) and then perform each link testing in a separate browser instance.

But I am having problem how to create copies of an already opened web page and open them?

  • What language are you using? Have you looked into using a single cookie from a login and then just using the cookie in new browser instances to prevent the log in steps? Selenium does not handle Multithreading and parallel execution well, sadly. – Paul Muir Sep 23 '16 at 11:51
  • I am using java, yes I am also thinking to copy the cookie from one browser to another but don't know how. – Nikunj Aggarwal Nov 22 '16 at 6:43
  • I think I can confidently say that you don't want to copy your webdriver object for parallelism. One driver instance binds to one browser window. For the sake of robustness, you'd be better off making 7 independent tests, that log in using 7 unique users with unique webdriver instances. And let your testing framework handle the parallelism. Keep your tests as simple and focused as possible – Julian Mar 22 '17 at 17:30
  • As per my answer, it's not intended to be possible and shouldn't be tested – Michael Durrant Mar 22 '17 at 18:37
0

I don't know how you had setup your scripts, I am not sure whether you have created any framework or running recorded script from Selenium IDE. But I can give you the Basic data flow structure that you could use to built your automation framework, which can run tests parallel or you can call same webdriver instance in multiple scripts.

1. Create a setup file which will instantiate the webdriver instance.

     public class Setup(){
     WebDriver d = new FirefoxDriver();
            @Before
            public void setup(){
                d.get("http://xyz.com");
            }
        }

2. Now create your testscript say LoginTest and extends Setup class, so that your driver instance will be available to other scripts or globally as shown,

    public Class LoginTest extends Setup {
    //start your test
    @Test
    public void testSomething(){
    // your script code clicking on link
    // you button press 
    }
    }   

    public Class SignUpTest extends Setup {
    //start your test
    @Test
    public void testSignup(){
    // your script code clicking on link
    // you button press 
    }
    }

Here @Test and @Before are TestNG(Unit Testing tool) annotations. Now create TestNG xml(name it testng.xml) file to run your tests which would be like this:

<?xml version="1.0" encoding="UTF-8"?>
 <suite name="example suite 1" verbose="1"  parallel="tests" thread-count="5">
      <test name="suite 1" >
        <classes>
          <class name="SignUpTest"/>
          <class name="LoginTest"/>
        </classes>
     </test>
    </suite>

Now you can run this testng.xml file and verify the above 02 tests will run in parallel. Same thing you can do with your scenario run 07 tests in parallel. Please refer to this link for best information on automated testing services details. Hope that help you.

Further If you provide more information about your question like what you have done, where you stuck with more details, I can help you in better way.

  • I have done almost some in my TestNG based framework. But the problem is single login on one time. So the solution you told will work fine if the same user is capable of logging in different browsers at the same time. But if my user login again it will terminate the previous session.So I want user to login first and then start parallel testing only after coming on the Home page. – Nikunj Aggarwal Aug 25 '16 at 5:24
0

It appears that the application does not allow multiple sessions.

Given this, testing will not be able to use multiple sessions either. Testing should only test the app 'as designed' and the design only allows for 1 session. Otherwise you are likely to start to run into either the issues that led to the application requiring one session or other new issues that don't occur when there is only 1 session as in the real world application.

  • I stand by my answer and I've updated the question title to reflect the specific details. – Michael Durrant Feb 20 '17 at 14:21
0

To be able to run tests in parallel you need to isolate your tests from each other.

You can isolate on different levels

  • Create a new unique users on start of the test
  • Create a fresh application environment for each test (Use containers like docker)
  • Create a unique database for the test to run

If you want to test specific functionality and not test that a system supports multiple users at the same time (which should be a separate test if you ask me) I like to combine these isolations.

This also prevents random fails because a test did not cleanup correctly or because changes to a dataset are depended on order of execution. As you delete the new database or environment everything is as clean as it gets.

Yes, your individual test run will be somewhat slower, waiting for database restore (milliseconds), for creation of users (milliseconds) or fresh containers (seconds). But the profit is parallelization on cloud level making test-runs to spawn up hundreds of machines. Fast continuous deployment cannot work without this eventually as your test-cases become more and more complex :)

0

Modify the application so that multiple sessions are allowed for the test environment(only).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.