Hey guys, today I will post about how can you setup your webdriver project to run in a remote machine.
So, first you need set a machine running the selenium server:
java -jar selenium-server-standalone-2.x.x.jar
You will see a message like this:
15:43:07.541 INFO - RemoteWebDriver instances should connect to:
http://127.0.0.1:4444/wd/hub
Then in your code, point webdriver.chrome.driver to the location of chromedriver on the remote machine, like the chrome driver. Also, make sure to start up chromedriver there. If you want to run on your local machine point to: 127.0.0.1:4444/wd/hub
String remoteURL = "http://localhost:9515"; System.setProperty("webdriver.chrome.driver", "/Users/xxxxx/chromedriver"); WebDriver driver = new RemoteWebDriver(new URL(remoteURL), DesiredCapabi lities.chrome()); driver.get("http://www.google.com"); WebElement element = driver.findElement(By.id("lst-ib")); element.sendKeys("Azevedo Rafaela!"); element.submit(); driver.quit();
Summarising: You have to install a Selenium Server (a Hub), and register your remote WebDriver to it. Then, your client will talk to the Hub which will find a matching webdriver to execute your test.
Hope this helps, a long time that I don’t code using Selenium!
Resources:
http://stackoverflow.com/questions/9542020/using-selenium-2-remotewebdriver-with-chromedriver