Running Selenium test cases in parallel on multiple systems.

98 views
Skip to first unread message

arjun

unread,
Feb 24, 2014, 5:53:34 AM2/24/14
to seleniu...@googlegroups.com
Hi,
I want to run my test cases in parallel on multiple platforms like different systems. I am executing test cases through Selenium Webdriver. I have configured Hub and more than 2 nodes and now want to run test cases in parallel.
Please help me guys if you have any knowledge regarding it.

Thanks.

Alex Hokanson

unread,
Feb 24, 2014, 6:59:51 AM2/24/14
to seleniu...@googlegroups.com
It sounds like you are almost there. If the hub is already up and you have at least one node connected, then the only thing left is to point your WebDriver instances to the hub URL. There is a wiki page on it at: https://code.google.com/p/selenium/wiki/Grid2

Krishnan Mahadevan

unread,
Feb 24, 2014, 7:04:44 AM2/24/14
to Selenium Users

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/


On Mon, Feb 24, 2014 at 5:29 PM, Alex Hokanson <avidga...@gmail.com> wrote:
It sounds like you are almost there. If the hub is already up and you have at least one node connected, then the only thing left is to point your WebDriver instances to the hub URL. There is a wiki page on it at: https://code.google.com/p/selenium/wiki/Grid2

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/26453b36-e29d-4138-9f4a-012de87056ff%40googlegroups.com.

Jayakrishnan Nair

unread,
May 29, 2017, 9:33:03 AM5/29/17
to Selenium Users
Hi Krishnan,
                   Try to run the selenium with browsermobProxy + Selenium+TestNG combination. I am getting below error when trying  to run the multiple threads 

Caused by: org.openqa.selenium.WebDriverException: Unable to bind to locking port 7054 within 45000 ms
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'IND-JNair', ip: '10.22.182.212', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_121'
Driver info: driver.version: FirefoxDriver
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'IND-JNair', ip: '10.22.182.212', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_51'
Driver info: driver.version: FirefoxDriver
    at org.openqa.selenium.internal.SocketLock.lock(SocketLock.java:99)
    at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:80)
    at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:271)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:119)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:218)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:129)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.openqa.selenium.remote.server.FirefoxDriverProvider.callConstructor(FirefoxDriverProvider.java:91)
    at org.openqa.selenium.remote.server.FirefoxDriverProvider.newInstance(FirefoxDriverProvider.java:68)
    at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(DefaultDriverFactory.java:60)
    at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:222)
    at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:1)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

Krishnan Mahadevan

unread,
May 29, 2017, 9:43:07 AM5/29/17
to seleniu...@googlegroups.com

The error doesn’t seem to have anything to do with parallel execution.

 

Have you tried to run just one single test for firefox ? To me it sounds like are having basic issues w.r.t firefox.

 

Can you please try using the latest version of :

 

  • Selenium (3.4.0)
  • GeckoDriver (v0.16.1)
  • Latest nightly build of Firefox

 

You can refer to this release notes of GeckoDriver for more information.

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

 

Message has been deleted

Jayakrishnan Nair

unread,
May 29, 2017, 1:36:04 PM5/29/17
to Selenium Users
Hi ,
      I am running selenium(2.53) and firefox 40 for my project. I am running the testng suite programmatically using thread pool executors. I also wanted to use WebDriverBackedSelenium to use old selenium functions.

//Below is the execution code.
public class AdminCourseDashboardExecutor implements Runnable {

    @Override
    public void run() {
         TestNG tng = new TestNG();
             List<XmlSuite> suiteslist = new ArrayList<XmlSuite>();           
            List<XmlTest> testlist  = new ArrayList<XmlTest>();
            List<XmlClass> classeslist = new ArrayList<XmlClass>();
            List<Class> listenerClasses = new ArrayList<Class>();
               
            XmlSuite suite = new XmlSuite();
            suite.setName("
AdminCourseDashboardSuite");
     
            XmlTest test = new XmlTest(suite);
            test.setName("AdminCourseDashboardTest");
          
     
            XmlClass clss1 = new XmlClass(AdminCourseDashboard.class.getName());
            clss1.setName("AdminCourseDashboardClass");
            classeslist.add(clss1);
            test.setXmlClasses(classeslist);
            testlist.add(test);
            suite.setTests(testlist);
            suiteslist.add(suite);
            tng.setXmlSuites(suiteslist);
  
            tng.run();
        }
       

    public static void main(String args[]) throws InterruptedException{
        /* Paramater
         * 1st Parameter - Test Class Name
         * 2nd Parameter - ThreadPool Size
         * 3rd Parameter - SuiteName
         * 4th Parameter - Time to Run
         * */
         // String ClassName  =  args[0];
          String Threadpoolsize =  args[0];
          String SuiteName =  args[1];
          String TimeToRun = args[2];
          System.out.println(Threadpoolsize+"   "+SuiteName+"   "+TimeToRun+"   ");
          ScheduledExecutorService scheduledThreadPool = Executors.newScheduledThreadPool(Integer.parseInt(Threadpoolsize));

            long startTime = System.currentTimeMillis();
            long TimeDuration1 =  Integer.parseInt(TimeToRun)*60*1000;
           
            //new AdminCourseDashboardExecutor().run();
         for(int i=0; i<10; i++)    {   
               Thread.sleep(20000);
                scheduledThreadPool.scheduleAtFixedRate(new AdminCourseDashboardExecutor(),5, 120, TimeUnit.SECONDS);
            }
           
            scheduledThreadPool.awaitTermination((startTime+TimeDuration1)-System.currentTimeMillis(), TimeUnit.MILLISECONDS);
            scheduledThreadPool.shutdown();
    }





//This is actual selenium code getting called.
public RemoteWebDriver browser;
    //public FirefoxDriver browser;
    public WebDriverWait wait;
    public WebDriverBackedSelenium selenium;
    public BrowserMobProxyServer proxybm;
    public PerformanceTiming timings;
    public Har pages;
    public String baseURL= "https://ras.sabacloud.com/";
    public readCSVFile csv = null;
    public Map<String,String>Configdata=null;
    public String URL;
   
   
   
    public void onFinish(ISuite arg0) {
        System.out.println("ISuite Data: Before Start"+arg0);
       
    }

    public void onStart(ISuite arg0) {
        System.out.println("ISuite Data: After Start"+arg0);
       
    }
   

    @BeforeSuite
    public void beforestart() throws IOException{
       
        Map<String,String> data = new HashMap<String,String>();       
           Configdata =  ConfigurationData.getInstance().getconfigData();
           int portnumber = findFreePort();
          
           try{
                Configdata.put("portnumber",String.valueOf(portnumber));
                proxybm =  BrowserMobProxyFactory.createInstance(Configdata);
                 BrowserMobProxyManager.setBrowserMobProxyServer(proxybm);
                Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxybm);
                DesiredCapabilities capabilities = DesiredCapabilities.firefox();          
               capabilities.setCapability(CapabilityType.PROXY, seleniumProxy);    
         
                       
         

         if(Configdata.containsKey("browser")){
             browser =     SabaWebDriverFactory.createWebDiverInstance(Configdata, capabilities);
             SabaWebDriverManager.setSabaWebDriverManager(browser);
            }
        
/*         if(Configdata.containsKey("filename")){
              String path =  Configdata.get("path");
              String filename =  Configdata.get("filename");
              File csvfile  =  new File(path+"\\"+filename);
              System.out.println(csvfile.toString());
              FileReader reader  =  new FileReader(csvfile);
              csv = new readCSVFile(reader);
         }*/
                
                 System.out.println("Creating Firefox Driver");
                 URL = (String)Configdata.get("AppURL");
                 timings = new PerformanceTiming();
                 pages  = new Har();
                 System.out.println(URL);
                selenium =  new WebDriverBackedSelenium(browser,URL);
                //selenium =     new WebDriverBackedSelenium
                 wait = new WebDriverWait(browser,120);
           }catch(Exception e){
                e.printStackTrace();
           }
        }

@AfterSuite
public void afterend(){
     System.out.println(pages.toString());
        try {
            pages.writeTo(new File("D:\\logs\\"+Thread.currentThread().getName()+".har"));
           
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
   
      proxybm.stop();
      browser.close();
}
   
 /*   @DataProvider(name="dataset")
    public Object[][] browserConfig(){
       
        Map<String,String> data = new HashMap<String,String>();
        String[] rowdata =  csv.getRowData();
        data =  csv.getRowToMap(rowdata);
        data.put("AppURL", URL);
        Object[][] dataobject = new Object[1][1];
        dataobject[0][0] = data;
        return dataobject;
       
    }*/
   
    public WebDriver getWebDriverInstance(){
         return browser;
    }
   
   
    public synchronized int  findFreePort() {
        int port=0;
        int srange=10000;
        int erange=50000;
        for(int i= srange; i<=erange;i++){

        try{   
          ServerSocket socket= new ServerSocket(i);      
          port = socket.getLocalPort();
          socket.close();
          break;
        }catch(IOException e){
          continue;      
         }
        }
        return port;
      }
   
}


Reply all
Reply to author
Forward
0 new messages