setup remote web driver to run on another machine | selenium webdriver

In A machine run your driver code, given below.


import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

public class RemoteDriver {

private WebDriver driver = null;

@Test
public void myTest() throws IOException, InterruptedException {
driver.get("http://www.google.com");

}

@Before
public void createDriver() throws MalformedURLException {
DesiredCapabilities capability = DesiredCapabilities.firefox();
driver = new RemoteWebDriver(new URL("http://10.1.1.202:4444(Machine b deteails)/wd/hub"), capability);
}

}

In B machine [IP = 10.1.1.202], run selenium standalone server using java -jar selenium-standalone-server.jar (note down the port which is running, you have to change the port in code accordingly). In default it will run on 4444

Execute the test in A – This will execute the given test in Remote machine using Firefox as browser.

No images available.