java -jar selenium-server-standalone-2.48.0.jar -role hub
java -jar selenium-server-standalone-2.48.0.jar -Dwebdriver.chrome.driver="D:/01 Learn WebDriver/chromedriver.exe" -role webdriver -hub http://localhost:4444/grid/register -port 5555 -browser browserName=chrome
java -jar selenium-server-standalone-2.48.0.jar -role webdriver -hub http://localhost:4444/grid/register -port 6666 -browser browserName=firefox
java -jar selenium-server-standalone-2.48.0.jar -Dwebdriver.ie.driver="D:/01 Learn WebDriver/IEDriverServer.exe" -role webdriver -hub http://localhost:4444/grid/register -port 7777 -browser browserName="internet explorer"
package test;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.Test;
public class grid2 {
@Test
public void test() throws MalformedURLException{
//grid
//chrome
DesiredCapabilities aaa = DesiredCapabilities.chrome();
String nodeurl = "http://localhost:5555/wd/hub";
URL url= new URL(nodeurl);
WebDriver dr = new RemoteWebDriver(url,aaa);
dr.get("https://www.baidu.com");
dr.findElement(By.id("kw")).sendKeys("hahaha");
//firefox
DesiredCapabilities bbb = DesiredCapabilities.firefox();
String nodeurl1 = "http://localhost:6666/wd/hub";
URL url1= new URL(nodeurl1);
WebDriver dr1 = new RemoteWebDriver(url1,bbb);
dr1.get("https://www.baidu.com");
dr1.findElement(By.id("kw")).sendKeys("hahaha");
//ie
DesiredCapabilities ccc = DesiredCapabilities.internetExplorer();
String nodeurl2 = "http://localhost:7777/wd/hub";
URL url2= new URL(nodeurl2);
WebDriver dr2 = new RemoteWebDriver(url2,ccc);
dr2.get("https://www.baidu.com");
dr2.findElement(By.id("kw")).sendKeys("hahaha");
dr.quit();
dr1.quit();
dr2.quit();
}
}