--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
public class SharedDriver extends EventFiringWebDriver { private static final WebDriver REAL_DRIVER; private static final Thread CLOSE_THREAD = new Thread() { @Override public void run() { REAL_DRIVER.quit(); } };static Properties OR = null;static String browser_name = null; static { System.out.println("I am in shareddriver static block "); System.out.println("setting property "); setProperty(); System.out.println("fetching browser now "); browser_name=fetchBrowser(); System.out.println(browser_name); System.out.println("I am in shareddriver static block- Property Set "); //System.setProperty("webdriver.chrome.driver", "C:/KM/dOWNLOADS_new/ChromeDriver/chromedriver.exe"); REAL_DRIVER= getInstance(browser_name); // REAL_DRIVER = new ChromeDriver(); REAL_DRIVER.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); Runtime.getRuntime().addShutdownHook(CLOSE_THREAD); } public static void setProperty(){ // initialize properties System.out.println("***************Initializing Properties file*******************"); try{ OR = new Properties(); FileInputStream fs = new FileInputStream(System.getProperty("user.dir")+"\\src\\test\\resources\\OR.properties"); OR.load(fs); }catch(Exception e){ System.out.println("Error in initializing Properties file"); } } public static String fetchBrowser() { browser_name=OR.getProperty("browser"); System.out.println("values fetched is"+browser_name); return browser_name; } static WebDriver driver; public static WebDriver getInstance(String browserName) {
switch (browser_name) { case "firefox": System.out.println("in firefox"); driver = new FirefoxDriver(); break; case "chrome": System.out.println("in chrome"); System.setProperty("webdriver.chrome.driver", "C:/KM/dOWNLOADS_new/ChromeDriver/chromedriver.exe"); driver = new ChromeDriver(); break; case "ie": System.out.println("in IE"); driver = new FirefoxDriver(); break; default: System.out.println("in Deafault"); driver = new FirefoxDriver(); break; } // maximize browser's window on start driver.manage().window().maximize(); return driver; }We used Gradle tasks to switch browsers, the Gradle task setting an environment variable for the browser and environnent, eg
gradle testDevFirefox
Then we had a Bamboo setup that executed separate tasks for each browser, triggered by a change in the test of Dev codebase. Each Bamboo track ran in a separate AWS instance, executing a Gradle task each.
Hope this helps,
Nick