SELENIUM GRID
- Launching IE, Chrome, Firefox Browsers with selenium Grid
public class Grid_TestCase {@Test
public void mailTest() throws MalformedURLException{
DesiredCapabilities dr=null;
String browserType ="Firefox";
WebDriver driver;
if(browserType.equals("Firefox")){
System.setProperty(GeckoDriverService.GECKO_DRIVER_EXE_PROPERTY,"C:\\Selenium_Projects\\Geo_Driver\\geckodriver.exe");
dr = DesiredCapabilities.firefox();
dr.setBrowserName("firefox");
dr.setPlatform(Platform.VISTA);
dr.setCapability("platform", "WIN7");
dr.setCapability("version", "53.0");
dr.setCapability("marionette", true);
dr.setCapability("acceptSslCerts", true);
driver=new RemoteWebDriver(new URL("http://10.76.174.34:5566/wd/hub"), dr);
driver.get("http://guru99.com");
String aName = driver.getTitle();
if(aName.contains("Guru")){
System.out.println("Test is passed");
}
else {
System.out.println("Test is Failed");
}
}
else if(browserType.equals("IE"))
{
System.setProperty("webdriver.ie.driver","C:\\Selenium_Projects\\Geo_Driver\\IEDriverServer.exe");
dr=DesiredCapabilities.internetExplorer();
dr.setBrowserName("internet explorer");
dr.setPlatform(Platform.VISTA);
driver=new RemoteWebDriver(new URL("http://10.76.174.34:5566/wd/hub"), dr);
driver.get("http://guru99.com");
String aName = driver.getTitle();
if(aName.contains("Guru"))
{
System.out.println("Test is passed");
}
else
{
System.out.println("Test is Failed");
}
}
else{
System.setProperty ("webdriver.chrome.driver","C:\\Selenium_Projects\\Geo_Driver\\chromedriver.exe" );
dr = DesiredCapabilities.chrome();
dr.setBrowserName("chrome");
dr.setPlatform(Platform.VISTA);
driver=new RemoteWebDriver(new URL("http://10.76.174.34:5566/wd/hub"), dr);
String eTitle = "Demo Guru99 Page1";
String aTitle = "" ;
// launch Chrome and redirect it to the Base URL
driver.get("http://demo.guru99.com/selenium/guru99home/" );
aTitle = driver.getTitle();
System.out.println("The string in the title is " + aTitle);
//compare the actual title with the expected title
if (aTitle.contentEquals(eTitle))
{
System.out.println( "Test Passed") ;
}
else {
System.out.println( "Test Failed" );
}
}
driver.close();
}
}
Comments
Post a Comment