pre requisites: jdk, eclipse with testng.
1. Download selenium server standalone jar
2. open command prompt and cd to the folder - where you have "selenium server standalone jar" available
ex:
cd E:\Selenium
3. start the hub from command prompt:
java -jar selenium-server-standalone.jar -role hub
4. run two nodes in diff vm or diff system (Replace localhost with hub system IP)
java -jar selenium-server-standalone.jar -role node -hub http://localhost:4444
5.verify your grid setup in below url.
http://localhost:4444/grid/console
5. Create one java project and convert into testng project.add selenium jar to buildpath
6. Update your testng.xml file with below code
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="methods">
<test name="Democart">
<classes>
<class name="testng.GridParreleltests"/>
</classes>
</test>
</suite>
7. Crate one testng class(GridParreleltests) under grid package and write below codes. note:- replace localhost with hub system IP.
package grid;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.Test;
public class GridParreleltests {
public static WebDriver driver;
@Test
public void test1() throws MalformedURLException {
String hubUrl="http://localhost:4444/wd/hub";
DesiredCapabilities cap= DesiredCapabilities.firefox();
//cap.setPlatform(Platform.WINDOWS);
// cap.setVersion);
cap.setBrowserName("firefox");
System.out.println("before launch");
driver =new RemoteWebDriver(new URL(hubUrl),cap);
driver.get("http://www.google.com");
System.out.println("after launch");
}
@Test
public void test2() throws MalformedURLException {
String hubUrl="http://localhost:4444/wd/hub";
DesiredCapabilities cap= DesiredCapabilities.chrome();
//cap.setPlatform(Platform.WINDOWS);
// cap.setVersion);
cap.setBrowserName("chrome");
System.out.println("before launch");
driver =new RemoteWebDriver(new URL(hubUrl),cap);
driver.get("http://www.yahoo.com");
System.out.println("after launch");
}
}
8. Right click on testng.xml and run as testng suite.
I like your blog very much and I would like to appreciate you. It was really wonderful blog. Keep it up.
ReplyDeleteBest Data Science Online Training Institute In Hyderabad
Thank you for sharing such a valuble information
ReplyDeletebest sap simple finance online training institute in hyderabad
Awesome blog. It was very informative. I would like to appreciate you. Keep updated like this best selenium training institute in hyderabad
ReplyDeleteClick Here Best RPA Online Training to go to RPA Online Training Institute Details .
ReplyDeleteGood Article..it's Was so informative..Thank You for shared..Keep update selenium training in chennai
ReplyDeleteselenium training in velachery
Animachi is really hard to recognize since you took over the website - what you made of it and I really appreciate your commitment to it
ReplyDeleteAll University BCOM TimeTable 2020