2

I want to perform multiple browser testing: While working on a project i needed to open multiple browsers simultaneously using Webdriver script.

Does anyone have experience in implementing this ?

1
  • 2
    in what language do you write your test scripts?
    – Theo
    Jul 8, 2013 at 12:59

2 Answers 2

8

Whether you want the ability to change the driver per execution of your tests, or simply rerun each test with multiple drivers, it's pretty straightforward. First you need to follow all of the instructions to get your drivers and browsers set up for the first execution. http://seleniumhq.org/docs/03_webdriver.jsp#selenium-webdriver-s-drivers.

In your code, it's also pretty straightforward, however you didn't mention a specific language or tool you're using to drive the automated tests... In C# some code may look like this:

        switch (browser)
        {
            case "Chrome":
                webDriver = new ChromeDriver();
                break;
            case "IE":
                webDriver = new InternetExplorerDriver();
                break;
            case "Firefox":
                FirefoxProfile profile = new FirefoxProfile();
                profile.AcceptUntrustedCertificates = true;
                webDriver = new FirefoxDriver(profile);
                break;
            default:
                Trace.WriteLine(String.Format("Browser '{0}' not recognized.  Spawning default Firefox browser.", browser));
                webDriver = new FirefoxDriver();
                break;
        }

If you wanted to execute everything in every browser (or at least every browser installed on a single machine), you could either create a foreach loop in your code, or if you're using something like nunit to execute the test cases, you could create parameterized tests that execute once for each parameter.

If you want additional info about how to execute on multiple versions of the same browser, or more detail about using a tool like nunit (or your specific tool) please clarify in your question.

3

I am not familiar with "Webdriver script", so I assume you are referring to a program that uses Selenium. You can write a program that opens multiple Drivers to talk to multiple simultaneous browsers. If you want that activity to happen in parallel, you will need to use multiple threads.

The specifics around how you open Drivers and use multiple threads depend upon the programming language.

2
  • +1 I just re-read the question and realized they most likely are asking how to open multiple browser windows simultaneously and not different browsers as my answer pointed to... Long holiday weekend :-)
    – Sam Woods
    Dec 26, 2012 at 23:30
  • @SamWoods I came here looking for answer about different browsers and your answer is exactly what I needed, maybe the question is a little ambiguous.
    – nullgraph
    Feb 20, 2016 at 2:11

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.