1. selenium-server-standalone-3.11.0.jar should download on our local machine. we can download this from here https://www.seleniumhq.org/download/
2. After that open the command prompt and go in to the drive where we have downloaded "selenium-server-standalone-3.11.0.jar" file and run the command "java -jar selenium-server-standalone-3.11.0.jar -role hub "
3. Once this will execute successfully we can see on console "Selenium Grid hub is up and running"
4. Now we can see GRID console on browser by opening this url: http://localhost:4444/grid/console
5. Now GRID is setup successfully
5. Now we have to register Node machine with GRID. For this we will open the node machine and download "selenium-server-standalone-3.11.0.jar", chrome driver, Firefox driver form here https://www.seleniumhq.org/download/
2. After that open the command prompt and go in to the drive where we have downloaded "selenium-server-standalone-3.11.0.jar" file and run the command "java -jar selenium-server-standalone-3.11.0.jar -role hub "
3. Once this will execute successfully we can see on console "Selenium Grid hub is up and running"
4. Now we can see GRID console on browser by opening this url: http://localhost:4444/grid/console
5. Now GRID is setup successfully
5. Now we have to register Node machine with GRID. For this we will open the node machine and download "selenium-server-standalone-3.11.0.jar", chrome driver, Firefox driver form here https://www.seleniumhq.org/download/
6. After that we have to register node machine with GRID by running this command using command prompt :
For Chrome Browser run this command using command prompt by changing chromedriver.exe location and port no
java -Dwebdriver.chrome.driver="put your chrome driver path\chromedriver.exe" -jar selenium-server-standalone-3.11.0.jar -role webdriver -hub http://localhost:4444/grid/register -port 5556 -maxSession 10 -browser browserName="Chrome",platform=WINDOWS
For Firefox Browser run this command using command promt by changing geckodriver.exe location and port no
java -Dwebdriver.gecko.driver="put your firefox driver path\Downloads\geckodriver.exe" -jar selenium-server-standalone-3.11.0.jar
-role webdriver -hub http://localhost:4444:4444/grid/register -port 5555 -maxSession 10 -browser browserName="firefox",platform=WINDOWS
-role webdriver -hub http://localhost:4444:4444/grid/register -port 5555 -maxSession 10 -browser browserName="firefox",platform=WINDOWS
7. After that we can see on console node is registred with grid successfully
8. Go to the GRID machine and referesh the grid console url : http://localhost:4444/grid/console
9. Now we can see two node with diffrente ip address and port no registered with GRID with browser name as well
8. Go to the GRID machine and referesh the grid console url : http://localhost:4444/grid/console
9. Now we can see two node with diffrente ip address and port no registered with GRID with browser name as well
Create Test Case Like this:
package testDemo;
import java.net.URL;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class TestGrid{
WebDriver driver;
String nodeUrl = "http://localhost:5555/wd/hub";
String baseUrl = "https://www.americangirl.com/shop/";
@BeforeTest
public void atBeforeTest() throws Exception{
DesiredCapabilities Dcp = new DesiredCapabilities();
Dcp = DesiredCapabilities.chrome();
Dcp.setBrowserName("chrome");
Dcp.setPlatform(Platform.ANY);
driver = new RemoteWebDriver(new URL(nodeUrl), Dcp);
}
@Test
public void atTest() throws Exception{
driver.manage().window().maximize();
driver.get(baseUrl);
System.out.println("Page title is : " + driver.getTitle());
System.out.println("Page current url is : " + driver.getCurrentUrl());
}
@AfterTest
public void closeWindow() throws Exception{
//driver.close();
}
}
Comments
Post a Comment