Home » Software Testing » Automation Testing » Selenium WebDriver Tutorial » How to execute Selenium WebDriver test cases parallel in multiple Browser using Testng parameter Annotation

How to execute Selenium WebDriver test cases parallel in multiple Browser using Testng parameter Annotation

Pre-Requisite:
Read these article before proceeding with this post:
Configuring Selenium Webdriver in Eclipse with Testng plugin installation..

I am supposing that you are familiar with how to add jar files to your project and How to add any  class, folder and xml.




Most of the time we find it hard to do compatibility testing of certain web-page on various Browsers and it takes a big chunk of time for its execution on various set of Browser and also on various instance of Browser.

Testng has provided us an option through its Parameter feature, through which we could run same test script written in WebDriver  parallel to all our installed Browser on our system.

Scripts and Steps to execute Script 

1- Go to your Eclipse Project –> Right Click on Project –> Click On New–> others–> Pop up would appear–> Click on XML –> Select XML File –> Click on Next –> New XML File pop up would appear–> Enter the name of XML and click on Finish

2- Your XML file would appear like this

  <?xml version=“1.0” encoding=“UTF-8”?>
<suite name=“Suite_2” parallel=“tests”>
<test name=“Funaction Test Cases “>
<parameter name=“browser” value=“Chrome” />
<classes>
<class name=“com.testng.Test” />
</classes>
</test> <!– Test –>

<test name=“Funaction Test Cases_Firefox “>
<parameter name=“browser” value=“Firefox” />
<classes>
<class name=“com.testng.Test” />
</classes>
</test>

<test name=“Funaction Test Cases_IE “>
<parameter name=“browser” value=“IE” />
<classes>
<class name=“com.testng.Test” />
</classes>
</test>

</suite> <!– Suite –>

Download xml file from here
Now understand the tags of XML that I have marked Bold in XML file
Parallel:  this is being used to run tests parallely in different browser
suite name: This is the name of your test suit
test name : kind of test cases (you may give name like this Regression, Sanity,Smoke, or any thing that make you to make better test execution ) like i have given name to this test case as Generic test
Classes: name of class that you want to add in this test execution
Most important one is

Here browser has been taken as parameter name(you can give name as per you choice) and FF for Firefox,IE for Internet Explorer, and Chrome for Chrome Browser are the various values given to this browser parameter that would be called in our code.




3- Now its time to understand how you have to use parameter name in Java program. Since parameter is defined for Browsers. Since you are trying to use Testng framework we would  write two function first one to launch Browser and Second one to close Browser

Create new java class in your Java Project
Steps to create new java class:: right click on project ||New|| Click on Class||Enter the name of class and Hit on finish.
Name of my java class is Browser.java so just create one class with name Browser and copy and paste following code in eclipse.

But before moving ahead i would suggest to go through following two post

1- Launching Chrome Browser
2- CHALLENGES TO RUN SELENIUM WEBDRIVER SCRIPTS IN IE BROWSER





4- Since we have created Browser class in which we have used the parameter defined in XML, Now we should create one more class that is our Test class, This class would inherit Browser class for launching Browser before executing scripts under @Test annotation and for Closing Browser once execution of scipt under @Test annotation get completed.
here I have given the name of this class is Test

5- Now its time to execute Test-Case
Steps:
Right Click on Test.java file and –> Run As –> Run Confinguration –> In pop up Go Testng –> Right Click on Testng and Click on New –> Give name to your Run Configuration, Browser Class and select your Xml just by Browsing in front of Suit –> hit on Finish and this would run your test

TestNg-ConfigHope this post would help you to run parallel WebDriver test case .

Friends I have tried these scripts on my system and are running well so if you find any missing bracket or braces missing then please do the correction at your own but Script is correct.

96 thoughts on “How to execute Selenium WebDriver test cases parallel in multiple Browser using Testng parameter Annotation”

  1. Hi, what does it mean by “select your Xml just by Browsing in front of Suit”?
    Note: I’m a total newbie.

      1. Thanks For your explanation, I am working on a similar flow, i am trying to restrict and reuse of existing open browsers.

        This article of yours has helped me and i found it usefull…

  2. I read the your blog but could not get XML file as you mentioned in –
    Scripts and Steps to execute Script
    1st Time Could you help me

    I am using Eclipse Indigo Version.

    Thanks,
    Shailesh

    1. Hi Shailesh
      I have just mention the line of code that would be included in xml for parallel execution of test in Browsers, In this post I have not attached any xml file but the lines of xnl code.So please go again to the heading
      Scripts and Steps to execute Script.

      1. Ok
        – Now I get my XML but’s it name is “testng-customesuite.xml” is there any difference between “testng.xml” and “testng-customesuite.xml”. It is present in Temp Folder i.e. C:Document and SettingsshaileshLocal SettingsTempTestng-eclipse 15466544(foldername)testng-customesuite.xml

        – I copied that file into my project because there is no way(or does not found) in eclipse(indo version) to view the XML. But your mentioned way does not work for me. 1- Go to your Eclipse Project –> Right Click on Project –> Click On New–> others–> Pop up would appear–> Click on XML –> Select XML File –> Click on Next –> New XML File pop up would appear–> Enter the name of XML and click on Finish

        – Also in Code
        if(browser.equalsIgnoreCase(“FF”))
        {
        System.out.println(“Firefox driver would be used”);
        driver = new FirefoxDriver();
        }

        It displays error as browser cannot be resolved.

        Right now I able to run Parallel test Case by following your step in one browser. Thanks.

        But Right now I not able to run test case into two different browser.

      2. Hi Dwarika,

        My Question is not how to luach other browser like Chrome or IE Or Firefox.

        My Question – In parallel testing I not able to lauch the Test Case in Different Browser like One in Chrome and Other is IE. Because it displays error at –

        if(browser.equalsIgnoreCase(“FF”))
        {
        System.out.println(“Firefox driver would be used”);
        driver = new FirefoxDriver();
        }

        It displays error as “browser”[in browser.equalsIgnoreCase(“FF”)] cannot be resolved.

        I can also send you mail of code if needed please give your mail id.

        Thanks for Prompt Reply!

        Shailesh.

          1. Hi Sir I’m trying to run test suite (tsestNG). But, when i run it’s opening multiple browser windows and then run one by one (Suppose in test suite have a 5 classes its open 5 browser windows and then run one by one). I want to run one by one but, after one class execution is complete then browser windows should close and then fresh window should open and run………
            my xml file is

      3. Hi Dwarika,

        I able to solve the Problem by changing just –
        @Parameter ({“browser”})
        //My setup method.

        But Right Now My test cases run Sequentially one after another. I followed all your step. WHY?

        My TestNG version – 6.8

        Thanks,
        Shailesh

        1. hai i also have same prblm pls snd me how to do compatibility testing on browser using selenium ..i will install testNG also but i got error msg.

  3. Hi

    i am unable to browse the class while doing:
    Right Click on Test.java file and –> Run As –> Run Confinguration –> In pop up Go Testng –> Right Click on Testng and Click on New –> Give name to your Run Configuration, Browser Class and select your Xml just by Browsing in front of Suit –> hit on Finish and this would run your test

    And therefore unable to run the test.
    Please help!

  4. Hey Dwarika Dhish Mishra,
    Please tell me to configure in eclipse Helios TestNG with Grid pls provide me steps.

    Thanks !!
    In Advance

  5. Hello
    Primarily thank you for this article.
    I have stuck up with an issue, hope that will be cleared with this blog.
    My Issue is i am running my jbehave (maven + selenium) stories in the browser i specified,
    But i need to run in multiple browsers with out switching.. means first it has to comple story in one browser and next with another browser.. Can you plzz help me out..
    T

    1. u can run multiple xml files within 1 xml file (testng). there is tag called . So create one file for each browser type, combine all of them into testngMaster.xml. Run testngMaster.xml, hope this helps

  6. [TestNG] Running:
    C:UsersPAppDataLocalTemptestng-eclipse-1762005051testng-customsuite.xml

    FAILED CONFIGURATION: @BeforeMethod openBroswer
    org.testng.TestNGException:
    Parameter ‘browser’ is required by @Configuration on method openBroswer but has not been marked @Optional or defined
    in C:UsersPAppDataLocalTemptestng-eclipse-1762005051testng-customsuite.xml
    at org.testng.internal.Parameters.createParameters(Parameters.java:155)
    at org.testng.internal.Parameters.createParameters(Parameters.java:358)
    at org.testng.internal.Parameters.createConfigurationParameters(Parameters.java:86)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:199)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:653)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
    at org.testng.TestRunner.privateRun(TestRunner.java:767)
    at org.testng.TestRunner.run(TestRunner.java:617)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
    at org.testng.SuiteRunner.run(SuiteRunner.java:240)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
    at org.testng.TestNG.run(TestNG.java:1057)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)

    SKIPPED CONFIGURATION: @AfterMethod closeBrowser
    SKIPPED: test

    ===============================================
    Default test
    Tests run: 1, Failures: 0, Skips: 1
    Configuration Failures: 1, Skips: 1
    ===============================================

    ===============================================
    Default suite
    Total tests run: 1, Failures: 0, Skips: 1
    Configuration Failures: 1, Skips: 1
    ===============================================

    [TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 37 ms
    [TestNG] Time taken by [email protected]: 34 ms
    [TestNG] Time taken by [email protected]: 7 ms
    [TestNG] Time taken by [email protected]: 10 ms
    [TestNG] Time taken by [email protected]: 39 ms
    [TestNG] Time taken by [email protected]: 5 ms

      1. Hi,
        sometimes this problem comes whle running your tests using TestNG.
        To resolve this error, you can do one thing that the file where you have created method for opening the browser (i.e the method to launch the application), just put a the below line with the method as:-
        public void openBrowser(@Optional(“firefox”) String Browser, @Optional(“”) String AppURL)
        {
        // Here your code for launching the app goes…..
        }

        Your error goes away…..after running this code..

        Please let me know if you are still facing such issue.

        Thanks
        Amit

        1. How to run multiple user login using webdriver + Eclips … can You
          plz provide the step by step procedure….

  7. Pingback: Selenium Best Links | Learn Testing

  8. Hi, I am new on selenium. I want to run selenium test case from console using webdriver in java. So please provide me appropriate information regarding this. What packages will be needed and what are steps need to follow for running this. Thanks in advance.

  9. My question is related to

    –driver.findElement(By.id(“gbqfq”)).sendKeys(“selenium”);
    There are no id’s in my FF with id “gbqfq”..

    –driver.findElement(By.xpath(“//ol[@id=’rso’]/li[1]//h3/a”)).click();
    from where did u get this Xpath — i am getting positional xPath by righclicking on third option..

    —How do we generalize that by default it should pick 3rd option for any search…
    i was searching for testng and it didnt click on third option.But it worked well for selenium

  10. I am getting NULL Pointer Exception
    <>
    =======
    XML file below
    ====================================================================

    –>

    =======
    Browser file below
    ====================================================================
    package test;

    import org.openqa.selenium.WebDriver;
    //import org.openqa.selenium.chrome.ChromeDriver;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.openqa.selenium.ie.InternetExplorerDriver;
    import org.openqa.selenium.support.ui.WebDriverWait;
    import org.testng.annotations.AfterMethod;
    import org.testng.annotations.Parameters;
    //import org.testng.annotations.AfterTest;
    import org.testng.annotations.BeforeMethod;

    public class Browser {

    //WebDriver driver;
    WebDriver webDriver = null;
    ReadDataFromExcel excelData = null;
    Contants var = new Contants();
    String[][] data = null;
    String[][] steps = null;
    WebDriverWait wait = null;
    TestUtilityMethods testUtil = new TestUtilityMethods();

    @BeforeMethod
    public void beforeMethod(){

    excelData = new ReadDataFromExcel();
    data = excelData.excelReadMethod(var.dataFile, var.productNameSheet);
    steps = excelData.excelReadMethod(var.stepsFile, var.stepsSheet);

    // Initialize the web driver & web Driver wait objects.
    webDriver = testUtil.keywordMethods(steps, webDriver);
    //webDriver = this.OpenBrowser(BROW)
    wait = new WebDriverWait(webDriver, 10);
    }

    @Parameters(“browser”)
    public void openBroswer(String browser){

    /*Comparing the value of parameter name if this is FF then It would launch Firefox and script that would run is as follows */
    if(browser.equalsIgnoreCase(“FF”))
    {
    System.out.println(“Firefox driver would be used”);
    webDriver = new FirefoxDriver();
    }
    else
    {
    System.out.println(“Ie webdriver would be used”);
    webDriver = new InternetExplorerDriver();
    }
    }

    @AfterMethod /* this annotation would run once test script execution would complete*/
    public void closeBrowser()
    {try{
    webDriver.wait(5000);
    }
    catch(Exception e){}
    webDriver.close();
    webDriver.quit();
    }

    }
    =======
    Test1.java file below
    ====================================================================
    package test;

    import static org.testng.Assert.assertEquals;

    import org.openqa.selenium.By;
    import org.openqa.selenium.support.ui.ExpectedConditions;
    import org.testng.Reporter;
    import org.testng.annotations.Test;

    @Test

    public class Test1 extends Browser {

    public void test1_LoginScreen() {
    System.out.println(“test After method”);

    try {
    //Wait for the login screen to render on screen.
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id(“customer-portal”)));

    //Locate elements and test with asserts.
    assertEquals(webDriver.getCurrentUrl().toString(), “http://localhost:8080/asm/asm_input”);
    System.out.println(“Assert Successful.”);
    } catch (Exception e) {
    // TODO Auto-generated catch block
    e.getMessage();
    }
    }

    }
    ====================================================================

    Any help will be appreciated 🙂

      1. OK so now it is running..issue was in the XML file. I was giving the wrong class name. But now it is only running for Firefox & not for IE….any suggestions?

      1. Hi Mate,

        I am having null pointer exception too so I wonder if you can share email that you sent to @akshatktshat please

        cheers

  11. Hello Dwarika,

    I have copy and pasted the same code and the same XML written by you.
    All the browser gets open parallel. But after finish the task in one browser, it get started in another than after finishing task in 2nd it gets performed in 3rd browser.

    I suppose the same action should get performed in all the browsers parallel.
    Please help me out.
    Thanks in advance.

      1. Yes Dwarika ,you are correct.
        Thanks for helping me out.

        I must appreciate your effort for writing these blogs.
        It helps me a lot

  12. org.testng.TestNGException: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 13; Open quote is expected for attribute “{1}” associated with an element type “name”.
    at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:341)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:88)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
    Caused by: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 13; Open quote is expected for attribute “{1}” associated with an element type “name”.
    atcom.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)

    Got this error for above code ,
    So i m unable to understand Error
    can any 1 help me for this ……………………………..!

    1. @Niyati

      There is problem in your xml …try to write allabove code manual because i have found it few time that copying above code is introducing some random string so try it manually or drop me a mail, i will send you the xml file that you can use for parallel execution

  13. @Dwarika
    I solved my all error in above program There is a problem in xml file only
    Modified XMl File :

    Btw Thanks again for such a nice concept 😀

  14. [TestNG] Running:
    C:UsersSatishAppDataLocalTemptestng-eclipse-1224165690testng-customsuite.xml

    FAILED CONFIGURATION: @BeforeMethod openBrowser
    org.testng.TestNGException:
    Parameter ‘browser’ is required by @Configuration on method openBrowser but has not been marked @Optional or defined
    in C:UsersSatishAppDataLocalTemptestng-eclipse-1224165690testng-customsuite.xml
    at org.testng.internal.Parameters.createParameters(Parameters.java:155)
    at org.testng.internal.Parameters.createParameters(Parameters.java:358)
    at org.testng.internal.Parameters.createConfigurationParameters(Parameters.java:86)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:199)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:653)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
    at org.testng.TestRunner.privateRun(TestRunner.java:767)
    at org.testng.TestRunner.run(TestRunner.java:617)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:335)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:330)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
    at org.testng.SuiteRunner.run(SuiteRunner.java:240)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
    at org.testng.TestNG.run(TestNG.java:1057)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)

    SKIPPED CONFIGURATION: @AfterMethod closeBrowser
    SKIPPED: test

    ===============================================
    Default test
    Tests run: 1, Failures: 0, Skips: 1
    Configuration Failures: 1, Skips: 1
    ===============================================

    ===============================================
    Default suite
    Total tests run: 1, Failures: 0, Skips: 1
    Configuration Failures: 1, Skips: 1
    ===============================================

    [TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 19 ms
    [TestNG] Time taken by [email protected]: 164 ms
    [TestNG] Time taken by [email protected]: 8 ms
    [TestNG] Time taken by [email protected]: 151 ms
    [TestNG] Time taken by [email protected]: 8 ms
    [TestNG] Time taken by [email protected]e5307e: 9 ms

      1. First of all thanks for quick reply.. but I heard that web driver by default maximize the browser where as in RC we have to use the command selenium.windowMaximize()..
        Please correct me if I am wrongh..

  15. hi i am new to testng . how do i give runtime arguments to testng vi ant ?? i want to create a runnable jar of my tests from command line with command line arguments . browser is firefox only.

  16. Pingback: Installing Maven Plugin in Eclipse | Abode QA

  17. Pingback: Handling JavaScript Alert in WebDriver | Abode QA

  18. Hi,

    I am able to open 2 parallel browsers using XML file. But all the executions of 2 tests are running in only one browser. Please help !!

  19. Hi Dwarika,

    I have used your code for running a test on different browsers but it is giving an error “Parameter ‘browser’ is required by @Configuration on method openBroswer but has not been marked @Optional or defined”

    My Code is given below please suggest me where i did mistake

    XML file:

    Broswer File:
    package com.testng;

    import java.util.concurrent.TimeUnit;

    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.openqa.selenium.ie.InternetExplorerDriver;
    import org.testng.annotations.AfterMethod;
    import org.testng.annotations.BeforeMethod;
    import org.testng.annotations.Parameters;

    public class Browser
    {

    WebDriver driver;

    @BeforeMethod
    @Parameters(“browser”)
    public void openBroswer(String browser)
    {

    /*Comparing the value of parameter name if this is FF then It would launch Firefox and script that would run is as follows */
    if(browser.equalsIgnoreCase(“FF”))
    {
    System.out.println(“Firefox driver would be used”);
    driver = new FirefoxDriver();
    driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
    }
    else
    {
    System.out.println(“Ie webdriver would be used”);
    driver =new InternetExplorerDriver();
    driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);

    }
    }
    @AfterMethod /* this annotation would run once test script execution would complete*/

    public void closeBrowser()
    {
    try
    {
    driver.wait(15000);
    }
    catch(Exception e){}
    driver.close();
    driver.quit();
    }
    }

    and My Test file:
    package com.testng;

    import java.util.concurrent.TimeUnit;

    import org.openqa.selenium.By;
    import org.testng.Reporter;
    import org.testng.annotations.Test;

    @Test

    public class Gmail_Login extends Browser
    {

    public void openbroswer()
    {

    driver.get(“http://www.google.com/”);
    driver.findElement(By.className(“gb_f”)).click();
    try
    {
    Thread.sleep(5000);
    }
    catch (InterruptedException e)
    {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }

    }

    }

    Please have look into this.

    Thanks in advance!

  20. Hi Dwarika,

    It is working fine on IE but on FF it is giving an below error:

    org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary(C:Program Files (x86)Mozilla Firefoxfirefox.exe) on port 7055; process output follows:
    *** LOG addons.manager: Application has been upgraded
    *** LOG addons.xpi: startup
    *** LOG addons.xpi: Skipping unavailable install location app-system-local
    *** LOG addons.xpi: Skipping unavailable install location app-system-share
    *** LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID: C:UsersManishAppDataLocalTempanonymous6754452699755471458webdriver-profileextensionswebdriver-staging
    *** LOG addons.xpi: checkForChanges
    *** LOG addons.xpi-utils: Opening XPI database C:UsersManishAppDataLocalTempanonymous6754452699755471458webdriver-profileextensions.json
    *** LOG addons.xpi: New add-on [email protected] installed in app-profile
    *** Blocklist::_loadBlocklistFromFile: blocklist is disabled
    *** LOG addons.xpi-utils: Make addon app-profile:[email protected] visible
    *** LOG DeferredSave/extensions.json: Save changes
    *** LOG DeferredSave/extensions.json: Save changes
    *** LOG addons.xpi: New add-on {972ce4c6-7e08-4474-a285-3208198ce6fd} installed in app-global
    *** LOG addons.xpi-utils: Make addon app-global:{972ce4c6-7e08-4474-a285-3208198ce6fd} visible
    *** LOG DeferredSave/extensions.json: Save changes
    *** LOG DeferredSave/extensions.json: Save changes
    *** LOG addons.xpi: New add-on [email protected] installed in winreg-app-global
    *** LOG addons.xpi-utils: Make addon winreg-app-global:[email protected] visible
    *** LOG DeferredSave/extensions.json: Save changes
    *** LOG DeferredSave/extensions.json: Save changes
    *** LOG addons.xpi: Updating database with changes to installed add-ons
    *** LOG addons.xpi-utils: Updating add-on states
    *** LOG addons.xpi-utils: Writing add-ons list
    *** LOG DeferredSave/extensions.json: Starting timer
    *** LOG DeferredSave/extensions.json: Starting write
    *** LOG DeferredSave/extensions.json: Write succeeded
    *** LOG addons.xpi-utils: XPI Database saved, setting schema version preference to 15
    *** LOG addons.manager: shutdown
    *** LOG addons.xpi: shutdown
    *** LOG addons.xpi-utils: shutdown
    *** LOG addons.xpi: Notifying XPI shutdown observers
    *** LOG addons.manager: Async provider shutdown done
    *** LOG addons.xpi: startup
    *** LOG addons.xpi: Skipping unavailable install location app-system-local
    *** LOG addons.xpi: Skipping unavailable install location app-system-share
    *** LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID: C:UsersManishAppDataLocalTempanonymous6754452699755471458webdriver-profileextensionswebdriver-staging
    *** LOG addons.xpi: checkForChanges
    *** LOG addons.xpi: No changes found
    JavaScript error: chrome://browser/content/urlbarBindings.xml, line 654: aUrl is undefined
    JavaScript error: chrome://browser/content/urlbarBindings.xml, line 654: aUrl is undefined
    JavaScript error: chrome://browser/content/urlbarBindings.xml, line 654: aUrl is undefined
    JavaScript error: chrome://browser/content/urlbarBindings.xml, line 654: aUrl is undefined
    JavaScript error: chrome://browser/content/urlbarBindings.xml, line 654: aUrl is undefined
    JavaScript error: chrome://browser/content/urlbarBindings.xml, line 654: aUrl is undefined

    Build info: version: ‘2.31.0’, revision: ‘1bd294d’, time: ‘2013-02-27 20:52:59’
    System info: os.name: ‘Windows 7’, os.arch: ‘x86’, os.version: ‘6.1’, java.version: ‘1.7.0_25’
    Driver info: driver.version: FirefoxDriver
    at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:118)
    at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:244)
    at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:110)
    at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:190)
    at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:183)
    at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:179)
    at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:92)
    at com.testng.Browser.openBroswer(Browser.java:27)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
    at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:564)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:653)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
    at org.testng.TestRunner.privateRun(TestRunner.java:767)
    at org.testng.TestRunner.run(TestRunner.java:617)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:335)
    at org.testng.SuiteRunner.access$000(SuiteRunner.java:37)
    at org.testng.SuiteRunner$SuiteWorker.run(SuiteRunner.java:369)
    at org.testng.internal.thread.ThreadUtil$2.call(ThreadUtil.java:64)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
    *** LOG addons.manager: Application has been upgraded
    *** LOG addons.xpi: startup
    *** LOG addons.xpi: Skipping unavailable install location app-system-local
    *** LOG addons.xpi: Skipping unavailable install location app-system-share
    *** LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID: C:UsersManishAppDataLocalTempanonymous6754452699755471458webdriver-profileextensionswebdriver-staging
    *** LOG addons.xpi: checkForChanges
    *** LOG addons.xpi-utils: Opening XPI database C:UsersManishAppDataLocalTempanonymous6754452699755471458webdriver-profileextensions.json
    *** LOG addons.xpi: New add-on [email protected] installed in app-profile
    *** Blocklist::_loadBlocklistFromFile: blocklist is disabled
    *** LOG addons.xpi-utils: Make addon app-profile:[email protected] visible
    *** LOG DeferredSave/extensions.json: Save changes
    *** LOG DeferredSave/extensions.json: Save changes
    *** LOG addons.xpi: New add-on {972ce4c6-7e08-4474-a285-3208198ce6fd} installed in app-global
    *** LOG addons.xpi-utils: Make addon app-global:{972ce4c6-7e08-4474-a285-3208198ce6fd} visible
    *** LOG DeferredSave/extensions.json: Save changes
    *** LOG DeferredSave/extensions.json: Save changes
    *** LOG addons.xpi: New add-on [email protected] installed in winreg-app-global
    *** LOG addons.xpi-utils: Make addon winreg-app-global:[email protected] visible
    *** LOG DeferredSave/extensions.json: Save changes
    *** LOG DeferredSave/extensions.json: Save changes
    *** LOG addons.xpi: Updating database with changes to installed add-ons
    *** LOG addons.xpi-utils: Updating add-on states
    *** LOG addons.xpi-utils: Writing add-ons list
    *** LOG DeferredSave/extensions.json: Starting timer
    *** LOG DeferredSave/extensions.json: Starting write
    *** LOG DeferredSave/extensions.json: Write succeeded
    *** LOG addons.xpi-utils: XPI Database saved, setting schema version preference to 15
    *** LOG addons.manager: shutdown
    *** LOG addons.xpi: shutdown
    *** LOG addons.xpi-utils: shutdown
    *** LOG addons.xpi: Notifying XPI shutdown observers
    *** LOG addons.manager: Async provider shutdown done
    *** LOG addons.xpi: startup
    *** LOG addons.xpi: Skipping unavailable install location app-system-local
    *** LOG addons.xpi: Skipping unavailable install location app-system-share
    *** LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID: C:UsersManishAppDataLocalTempanonymous6754452699755471458webdriver-profileextensionswebdriver-staging
    *** LOG addons.xpi: checkForChanges
    *** LOG addons.xpi: No changes found
    JavaScript error: chrome://browser/content/urlbarBindings.xml, line 654: aUrl is undefined
    JavaScript error: chrome://browser/content/urlbarBindings.xml, line 654: aUrl is undefined
    JavaScript error: chrome://browser/content/urlbarBindings.xml, line 654: aUrl is undefined
    JavaScript error: chrome://browser/content/urlbarBindings.xml, line 654: aUrl is undefined
    JavaScript error: chrome://browser/content/urlbarBindings.xml, line 654: aUrl is undefined
    JavaScript error: chrome://browser/content/urlbarBindings.xml, line 654: aUrl is undefined

    at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:106)
    … 30 more

    1. Please downgrade your firefox or try most recent Selenium Standalone jar. This problem occurs only when Standalone jar’s version does not support the current version of Firefox.
      So try this once again with downgrading the firefox

  21. Hi Dwarika,

    Currently i am working on Object Repository of selenium.

    I want to get the attribute value of all the element present on a web page along with the count of the element.

    So please suggest me what should i do first and how can i do that.

    Thanks in Advance!

  22. @Manish
    Please search Web, u can get plenty- Here is one example:
    driver.findElement(By.id(“idoftheelem”)).getAttribute(“value”);

    @Dwarika
    Nice and excellent!
    Thanks for your time and help!
    Have u ever worked with BDD (RobotFramework / JBehave)

  23. @Dwarika,

    If we use the single and same WebDriver object for more than 1 class/test for Parallel runs, will this create problem ?
    Because more than one class are using the samea WebDriver object (though for IEDriver and FFdriver are separate things)

    Thanks

    1. No we are not using same object in multiple classes, actually here we are using Parametrization and here we are just changing the parameter with FF, IE or with Chrome and whenever code is seeing IE or FF or Chrome then it is calling the respective browser.

  24. Thanks for the reply!

    Sorry, I did not see any JUnit specific topi, so posting here.

    I need your advice.
    I am using – JUnit +Eclipse +Java+Webdriver.
    I want to use Assumes in my Java files, so if the 1st method fails, the subsequent methods won’t run.

    For this, I tried to use Corollaries.java which is at Github.com

    My example Java file:
    ——————-
    import junit.framework.Assert;
    import org.junit.Rule;
    import org.junit.contrib.assumes.Corollaries;
    import org.junit.runner.RunWith;
    import……………………

    @RunWith(Corollaries.class)
    public class myC()
    {
    }
    ——————————–

    My problem is, I could not understand how to use it.

    I put the Corollaries.java in my package.
    But getting error at —–
    Assumes assumptions = method.getAnnotation(Assumes.class);

    The error says that Assumes class is not extending the Annotations.

    Can u help.

    Best regards,

  25. hi Dwarika,

    Thanks for writing this …..
    How to distribute tests among different browsers?
    Have to run some of the tests on 1 browser, some on other to distribute the load (I have 40 tests in excel sheet, so takes more than an hour to complete the test, so thought, distributing them among different browsers will help out) so I’m exploring selenium grid,
    Have registered hub and nodes, have run one test ex.
    DesiredCapabilities capability = DesiredCapabilities.firefox();
    capability.setCapability(“browser”, “firefox”);
    capability.setCapability(“browser_version”, “Linux”);
    capability.setCapability(“os”, “7”);
    capability.setCapability(“os_version”, “17.0”);
    capability.setCapability(“browserstack.debug”, “true”);
    WebDriver driver = new RemoteWebDriver(new URL(“http://localhost:4444/wd/hub”), capability);
    driver.get(“http://www.google.com”);

    But it runs only once and on 1 browser at a time. (I can parametrize it with TestNg and run same with different browsers parallel like you said, but it runs same test in different browsers not distributes the tests)
    So how should I modify it to distribute my tests let say open 5 browsers (1st browser runs-1st 8 tests, 2nd runs-next 8 tests and so on)?

    I’m Using
    Java+ WebDriver+Maven+TestNg and controlling tests on Jenkins

  26. Pingback: How to execute Selenium WebDriver test cases pa...

  27. Sumit Kumar Mishra

    Hi Dwarika,

    I am new in automation testing and trying to setup hybrid automation framework in our organization.

    Please can you guide me or do you have any demo of hybrid framework design?

    My mail id : [email protected]

  28. Hi Dwarika,

    Can you please tell me that in the Selenium webdriver, if I have a button on a webpage wherein its location is continuously changing, then how do i write the xpath for that button?? Will the xpath remain same or how

  29. Hi Dwarika Dhish Mishra,

    Thank you for your blog, for giving a chance to others learn from you!

    My question might be simple, but I struggle to find a solution. In your example you run in parallel tests on different browser type.

    I have key-driven build framework where each test cases set are in Excel spreadsheet. For example I ran spreadsheet S1 and S2 where S1 has all login test cases and S2 has all email validation test cases. I have more than 2 of cause.

    Question:

    I do NOT want to run S1,S2… on FF and IE on two different browsers. How to set up testng.xml to be able to run S1, S2 etc in parallel using same browser, say FF. I want to speed up execution of all test cases against one browser.

    Thank you for your help,
    Natalie

  30. I tried this program it is just showing the result . it did not perform any action on browser.

    [TestNG] Running:
    C:\Users\Day\AppData\Local\Temp\testng-eclipse-275109580\testng-customsuite.xml

    ===============================================
    Default test
    Tests run: 0, Failures: 0, Skips: 0
    ===============================================

    ===============================================
    Default suite
    Total tests run: 0, Failures: 0, Skips: 0
    ===============================================

    [TestNG] Time taken by [email protected]: 6 ms
    [TestNG] Time taken by [email protected]: 34 ms
    [TestNG] Time taken by [email protected]: 71 ms
    [TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 0 ms
    [TestNG] Time taken by [email protected]: 0 ms
    [TestNG] Time taken by [email protected]: 55 ms
    Picked up _JAVA_OPTIONS: -Xmx512M

  31. Pingback: Testing Web Apps In Multiple Broswers – (continued) | save picture

  32. Hi Dwarika,

    I am trying parallel execution in same browser. It has created two result folders but When creating result files (Excel) it is failed to create. How to create two excel report file for the same time to the respective folders.

    Error shows as below

    Cannot create EXCEL File, test case stop.Failed, Create Excel ‘ExcelResult_5_FEB_2015_08_35_18.xls’ has error is occur. (null)
    ================================> Cannot create EXCEL File, test case stop.Feb 05, 2015 8:35:22 AM org.openqa.selenium.os.UnixProcess$SeleniumWatchDog destroyHarder
    INFO: Command failed to close cleanly. Destroying forcefully (v2). [email protected]

  33. I learned a lot at thedevmasters.com. It is an amazing service special there mentoring program gave me real hand on experience in troubleshooting. I was able to create a full “Sports Statistics Scripts write a script to process data using selenium tools.” in less than 6 hour time all by myself. Amazing professional team of mentors and software educators. Visit http://www.thedevmasters.com and [email protected], 1(866)340-1375

  34. When Ioriginally commented I clicked the “Notify me when new comments are added” checkbox and now
    each time a comment is added I get three e-mails with the same comment.
    Is there any way you can remove me from that service?
    Cheers!

  35. Pingback: Mobile emulation in Google Chrome using Selenium WebDriver - Abode QA

  36. Hi,
    My requirement is that while the method under @Test is getting executed I want to print the browser on which it is getting executed.How would I be abLe to do that?

  37. i have configured all as per the steps mentioned and is running as well without error.
    But is is not opening any browser just giving me below result –
    [TestNG] Running:
    C:\Users\ssha65\AppData\Local\Temp\testng-eclipse–1069124013\testng-customsuite.xml

    ===============================================
    Default test
    Tests run: 0, Failures: 0, Skips: 0
    ===============================================

  38. Hi,

    I am able to open 2 parallel browsers using XML file. But all the executions of 2 tests are running in only one browser. Please help !!

  39. Wow, what a explanation!! Thanks a lot man 🙂 Your blog is awesome and also I’m wondering about the discussion here. All my doubts are cleared in your discussion. Thank you very much. I would like to visit your blog often. Keep Rocking.

  40. Hi Dwarika!

    In xml containing 5 classes, i have given parallel = “classes” thread-count=”2″.But I want to run the test cases sequentially but I do not want to make changes in the xml file. When I tried using listener (IAnnotationTransformer) anotation.setSequential=”true” and I also tried at the @Test by providing sequential=”True” and singleThreaded=”True”. It still executes in parallel. Is there anyway to solve this.

    Thanks,
    Sunil

  41. Vaishnavi Chheda

    Thanks for a great blog.
    But I am unable to start the run the test on any browsers.
    The browser opens but nothing happens after.

    FF: 52.0
    MacOs: Sierra

  42. Hi dwarika,

    How to do the HOW TO EXECUTE SELENIUM WEBDRIVER TEST CASES PARALLEL IN MULTIPLE BROWSER USING junit+selenium webdriver+maven….

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: