LambdaTest Community

Find answers, support, and inspiration from other users

Questions
LambdaTest Community
Answered

How can I run Selenium tests in multiple browsers?

Can anyone please provide me some knowledge regarding how i can run selenium tests in multiple browsers.

Up Vote Down Vote 0 Votes
Posted 4 months ago

Answers


We have multiple browsers for automation testing using selenium webdriver like Google Chrome, Mozilla Firefox, IE, HTML Unitdriver.

Here you can use all the above mentioned webdrivers as Headed drivers as well as Headless drivers.

For multiple browsers you can go through the below script

WebDriver driver;

@BeforeTest

@Parameters("browser")

public void setup(String browser) throws Exception{

if(browser.equalsIgnoreCase("firefox")){

System.setProperty("webdriver.gecko.drive", ".\\geckodriver.exe");

driver = new FirefoxDriver();

}

else if(browser.equalsIgnoreCase("chrome")){

System.setProperty("webdriver.chrome.driver",".\\chromedriver.exe");

driver = new ChromeDriver();

}

else if(browser.equalsIgnoreCase("Edge")){

System.setProperty("webdriver.edge.driver",".\\MicrosoftWebDriver.exe");

driver = new EdgeDriver();

}

else{

throw new Exception("Browser is not correct");

}

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

}

@test

public static void(){

*********you can write your script here.**********

}
Up Vote Down Vote 0 Votes
Posted 3 months ago