0

My problem here that I want to run feature cucumber in parallel on multiple browser. So for that I didn't use a feature. I wrote this method to run test in parallel :

public WebDriver driver;
    @Parameters("myBrowser")
    @BeforeClass
    public void launchBrowser(@Optional("optional value") String myBrowser) {
        if(myBrowser.equalsIgnoreCase("ie")) {
            System.setProperty("webdriver.ie.driver","C:\\Driver\\IEDriverServer\\IEDriverServer_32bits.exe");
            driver = new InternetExplorerDriver();
        }else if (myBrowser.equalsIgnoreCase("chrome")) {
            System.setProperty("webdriver.chrome.driver","C:\\Drive\\chromedriver_win32\\chromedriver.exe");
            driver= new ChromeDriver();
        }
        else if(myBrowser.equalsIgnoreCase("ff")) {
        System.setProperty("webdriver.gecko.driver","C:\\Drive\\geckodriver-v0.20.0-win64\\geckodriver.exe");
        driver = new FirefoxDriver();
        }
    }

And in testng.xml this :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="tests">

  <test  name="IETest">
  <parameter name="myBrowser" value="ie" />


  <classes>
  <class name="com.testparallel.ParallelTesting.ParallelTestExecution" />
  </classes>
  </test> 

  <test  name="FirefoxTest">
  <parameter name="myBrowser" value="ff" />


  <classes>
  <class name="com.testparallel.ParallelTesting.ParallelTestExecution" />
  </classes>
  </test> 

  <test  name="ChromeTest">
    <parameter name="myBrowser" value="chrome" />


  <classes>
  <class name="com.testparallel.ParallelTesting.ParallelTestExecution" />
  </classes>
  </test> <!-- Test -->
</suite> <!-- Suite -->

And a test methods with @Test, but now i want to integrate or make a link between the methods with @Test annotation and a feature cucumber. Is there any solution to fixed !

I think taht Cucumber-jvm its not to run in different browser i mean to open multiple browser

And here I have 2 features ,2steps and 2 runners. In the script I have 2 similaire methods so I created Globalstep and defined them here, but when I run the in 2 browser they don't executed those methods ?

user6618310
  • 39
  • 1
  • 5
  • 14
  • Use the testng runner for running cucumber features.https://github.com/cucumber/cucumber-jvm/tree/master/testng/src/main/java/cucumber – Grasshopper Apr 16 '18 at 18:06
  • i tried but with cucumber jvm i can't run them in parallel on multiple browser – user6618310 Apr 16 '18 at 18:36
  • Yes u can by using maven failsafe plugin. Create runners for each kind of browser ie, for running in 3 different browsers for a feature file(s) code 3 runners. Instantiate the appropriate browser and pass it to the pageobject. Even better use a DI tool like picocontainer to handle object creation. – Grasshopper Apr 16 '18 at 19:22
  • thx, It works for me but is there any possibility to run the 3 features with the same methods (same stepdefinition ) except the open browser ! i tested but the test failed? – user6618310 Apr 17 '18 at 14:46
  • No need to create multiple similar step definitions. What is the error you are getting? – Grasshopper Apr 17 '18 at 14:55
  • The problem that I work in a big project for that for 10 existance features i will duplicate them to 30 and then duplicate the stepdefinition and finally to duplicate the runner ! Is it like that ? – user6618310 Apr 18 '18 at 07:48
  • You just need to duplicate runners. Have a look at this plugin. This does all the hard work. https://github.com/temyers/cucumber-jvm-parallel-plugin – Grasshopper Apr 18 '18 at 08:20
  • I don't understand how do I use the cucumber-jvm in this field I updated here can you check please, thank you. – user6618310 Apr 18 '18 at 10:19
  • I think this is someting similar to what you are trying. https://stackoverflow.com/questions/43446922/cross-browser-testing-in-cucumber/43481943#43481943 – Grasshopper Apr 18 '18 at 15:47

0 Answers0