Multiple Browser Passing as Parameters
The Parameter "browser" is passed from TestNG.xml as below:
@Parameters("browser") @BeforeClass public void beforeTest(String browser) { if (browser.equalsIgnoreCase("firefox")) { FirefoxProfile firefoxProfile = new ProfilesIni().getProfile("default"); driver = new FirefoxDriver(firefoxProfile); } else if (browser.equalsIgnoreCase("chrome")) { // Set Path for the executable file System.setProperty("webdriver.chrome.driver","D:\\Automation Project WorkSpace\\Experience\\lib\\chromedriver.exe"); driver = new ChromeDriver(); } else if (browser.equalsIgnoreCase("ie")) { // Set Path for the executable file System.setProperty("webdriver.ie.driver", "D:\\Automation Project WorkSpace\\Experience\\lib\\IEDriverServer.exe"); driver = new InternetExplorerDriver(); } else { throw new IllegalArgumentException("The Browser Type is Undefined"); } // Open App driver.get("https://www.google.com"); }
No comments:
Post a Comment