Is there any solutions for executing multiple selenium webdriver java test-scripts having different parameters at one time and get results.
If parameter is URLs, then we can test multiple Urls on one browserNames i.e Chrome, Firefox, Microsoft Edge, etc. as both sequential & parallel test execution.
But If parameter is browserNames, then we can achieve only sequential test execution.
Now, clear objective is to achieve parallel test execution of common test-script(selenium webdriver) to run on multi web browsers (chrome, firefox , edge, etc.) at sametime to get Test Pass/Fail.
So, Is it possible to achieve parallel test execution ?
I have code example, which leads this desiring idea :-
package InternetTestWebsite;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class TestData1 {
public static void main(String[] args) {
String baseUrl = "https://www.saucedemo.com";
String browserName = "chrome";
LoginThePage(browserName, baseUrl);
}
public static void LoginThePage(String browserNameforTestExecution, String baseUrl) {
try {
WebDriver driver;
if (browserNameforTestExecution.equalsIgnoreCase("firefox")) {
System.setProperty("webdriver.gecko.driver", ".\\geckodriver.exe");
driver = new FirefoxDriver();
} else if (browserNameforTestExecution.equalsIgnoreCase("chrome")) {
System.setProperty("webdriver.chrome.driver", ".\\chromedriver.exe");
driver = new ChromeDriver();
} else if (browserNameforTestExecution.equalsIgnoreCase("Edge")) {
System.setProperty("webdriver.edge.driver", ".\\MicrosoftWebDriver.exe");
driver = new EdgeDriver();
} else {
throw new Exception("Browser is not correct");
}
driver.get(baseUrl);
driver.manage().window().maximize();
WebElement username = driver.findElement(By.xpath("//input[@type='text']"));
username.clear();
username.sendKeys("standard_user");
WebElement password = driver.findElement(By.xpath("//input[@type='password']"));
password.clear();
password.sendKeys("secret_sauce");
WebElement loginbtn = driver.findElement(By.xpath("//input[@type='submit']"));
loginbtn.click();
} catch (Exception e) {
e.printStackTrace();
}
}
}