Eajaz
Eajaz

Reputation: 479

Need help on Cucumber Selenium JAVA for multi browsers

I want to use Cucumber framework with Selenium WebDriver+JAVA. This is for development of our automation framework. I automated many scenarios on FF browser. I want to run my tests on multiple browsers. I browsed through the net, couldn't get any concrete solution. Can some one please help me on its implementation.

  1. src/main/java > Has all the page objects
  2. src/main/resources > Has nothing
  3. src/test/java > Has RunTests.java and TestRunner.java
  4. src/test/resources > Has my feature file.

Any help on this will be greatly appreciated.

Upvotes: 1

Views: 1442

Answers (2)

QASource
QASource

Reputation: 85

Please follow these steps that may be helpful for you

  1. Download drivers of the browsers say IEDriver for internet explorer etc

  2. Place the .exe file into your project

  3. In the class that instantiate the webdriver or browser initialize the required browser like this:

    private static DesiredCapabilities DESIRED_CAPABILITIES;

public static WebDriver getInstance() {

if (WEB_DRIVER == null)
{
WEB_DRIVER = new FirefoxDriver(DESIRED_CAPABILITIES);
}
return WEB_DRIVER;
}
  1. Replace Firefox with IE in the file from where you are calling the Firefox driver.

Upvotes: 0

jmccure
jmccure

Reputation: 1259

Parameterise where you are instantiating your FF Webdriver object so that it can take a browser type, e.g. FF, Chrome, IE. From this variable return a different Webdriver object e.g. ChromeDriver, InternetExplorerDriver etc.

To learn about instantiating different browser types, search google or see: http://www.qaautomation.net/?p=373

From there you can feed this method a variable or set an environment variable through your CI (e.g. Jenkins) job which will hold the browser type for the test run.

Upvotes: 0

Related Questions