Skip to content

Instantly share code, notes, and snippets.

@djangofan
Forked from testingbot/gist:2428497
Created November 21, 2012 19:24
Show Gist options
  • Save djangofan/4127074 to your computer and use it in GitHub Desktop.
Save djangofan/4127074 to your computer and use it in GitHub Desktop.
Selenium-2 Remote WebDriver Example
//use testingbot.com or saucelabs or roll your own remote webdriver server
import junit.framework.TestCase; //removes need for annotations by extending
import org.openqa.selenium.*;
import org.openqa.selenium.remote.*;
import java.net.URL;
import java.util.concurrent.TimeUnit;
public class RWDTest extends TestCase {
private WebDriver driver;
public void setUp() throws Exception {
DesiredCapabilities abilities = DesiredCapabilities.firefox();
capabillities.setCapability("version", "16");
capabillities.setCapability("platform", Platform.WINDOWS);
capabillities.setCapability("name", "Testing Selenium-2 Remote WebDriver");
driver = new RemoteWebDriver( new URL("http://key:secret@hub.testingbot.com:4444/wd/hub"), abilities);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.manage().window().setPosition(new Point(220, 10));
driver.manage().window().setSize(new Dimension(1000,650));
}
public void testSimple() throws Exception {
this.driver.get("http://www.google.com");
assertEquals("Google", this.driver.getTitle());
}
public void tearDown() throws Exception {
this.driver.quit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment