Java Code Examples for org.openqa.selenium.remote.RemoteWebDriver#get()

The following examples show how to use org.openqa.selenium.remote.RemoteWebDriver#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BmiCalculatorTest.java    From Selenium-WebDriver-3-Practical-Guide-Second-Edition with MIT License 6 votes vote down vote up
@BeforeMethod
public void setUp() throws Exception {

    String SAUCE_USER = "upgundecha";
    String SAUCE_KEY = "5768f2a9-33be-4ebd-9a5f-3826d7c38ec9";

    DesiredCapabilities caps = new DesiredCapabilities();
    caps.setCapability("platform", "OS X 10.9");
    caps.setCapability("browserName", "Safari");
    caps.setCapability("name", "BMI Calculator Test");
    driver = new RemoteWebDriver(
            new URL(MessageFormat.format("http://{0}:{1}@ondemand.saucelabs.com:80/wd/hub'",
            SAUCE_USER, SAUCE_KEY)), caps);
    driver.get("http://bit.ly/1zdNrFZ");

}
 
Example 2
Source File: LocalServerWebDriverContainerTest.java    From testcontainers-java with MIT License 6 votes vote down vote up
@Test
public void testConnection() {
    // getWebDriver {
    RemoteWebDriver driver = chrome.getWebDriver();
    // }

    // Construct a URL that the browser container can access
    // getPage {
    String hostIpAddress = chrome.getTestHostIpAddress();
    driver.get("http://" + hostIpAddress + ":" + localPort);
    // }

    String headingText = driver.findElement(By.cssSelector("h1")).getText().trim();

    assertEquals("The hardcoded success message was found on a page fetched from a local server", "It worked", headingText);
}
 
Example 3
Source File: SauceExecutionTest.java    From demo-java with MIT License 6 votes vote down vote up
@Test
public void sauceExecution() throws MalformedURLException {
    // 1. Specify the 3 basic parameters of a SauceOptions instance
    SauceOptions sauceOptions = new SauceOptions();
    sauceOptions.setBrowserName(Browser.FIREFOX);
    sauceOptions.setBrowserVersion("73.0");
    sauceOptions.setPlatformName(SaucePlatform.WINDOWS_8);

    // 2. Create Session object with the Options object instance
    SauceSession session = new SauceSession(sauceOptions);

    // 3. Start Session to get the Driver
    RemoteWebDriver driver = session.start();

    // 4. Use the driver in your tests just like normal
    driver.get("https://www.saucedemo.com/");

    // 5. Stop the Session with whether the test passed or failed
    session.stop(true);
}
 
Example 4
Source File: AndroidJupiterTest.java    From selenium-jupiter with Apache License 2.0 5 votes vote down vote up
@Disabled
// tag::snippet-in-doc[]
@Test
public void testAndroid(
        @DockerBrowser(type = ANDROID, version = "8.1", deviceName = "Nexus S") RemoteWebDriver driver) {
    driver.get("https://bonigarcia.github.io/selenium-jupiter/");
    assertThat(driver.getTitle(),
            containsString("JUnit 5 extension for Selenium"));
}
 
Example 5
Source File: AndroidCustomJupiterTest.java    From selenium-jupiter with Apache License 2.0 5 votes vote down vote up
@Disabled
// tag::snippet-in-doc[]
@Test
public void testAndroid(@DockerBrowser(type = ANDROID, version = "9.0",
        deviceName = "Nexus S") RemoteWebDriver driver) {
    driver.get("https://bonigarcia.github.io/selenium-jupiter/");
    assertThat(driver.getTitle(),
            containsString("JUnit 5 extension for Selenium"));
}
 
Example 6
Source File: ServerJupiterTest.java    From selenium-jupiter with Apache License 2.0 5 votes vote down vote up
@ParameterizedTest
@MethodSource("capabilitesProvider")
void testServer(Capabilities capabilities) throws MalformedURLException {
    String serverUrl = String.format("http://localhost:%s/wd/hub/",
            serverPort);
    RemoteWebDriver driver = new RemoteWebDriver(new URL(serverUrl),
            capabilities);
    assertNotNull(driver);
    driver.get("https://bonigarcia.github.io/selenium-jupiter/");
    assertThat(driver.getTitle(),
            containsString("JUnit 5 extension for Selenium"));
    driver.quit();
    assertNull(driver.getSessionId());
}
 
Example 7
Source File: HostPortExposedTest.java    From testcontainers-java with MIT License 5 votes vote down vote up
@Test
public void testContainerRunningAgainstExposedHostPort() {
    // useHostExposedPort {
    final String rootUrl =
        String.format("http://host.testcontainers.internal:%d/", localServerPort);

    final RemoteWebDriver webDriver = browser.getWebDriver();
    webDriver.get(rootUrl);
    // }

    final String pageSource = webDriver.getPageSource();
    assertTrue(pageSource.contains("Hello World!"));
}
 
Example 8
Source File: DockerChromeJupiterTest.java    From selenium-jupiter with Apache License 2.0 5 votes vote down vote up
@Test
public void testChrome(
        @DockerBrowser(type = CHROME) RemoteWebDriver driver) {
    driver.get("https://bonigarcia.github.io/selenium-jupiter/");
    assertThat(driver.getTitle(),
            containsString("JUnit 5 extension for Selenium"));
}
 
Example 9
Source File: WebDriverContainerLiveTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void whenNavigatedToPage_thenHeadingIsInThePage() {
    RemoteWebDriver driver = chrome.getWebDriver();
    driver.get("http://example.com");
    String heading = driver.findElement(By.xpath("/html/body/div/h1"))
        .getText();
    assertEquals("Example Domain", heading);
}
 
Example 10
Source File: FlakyContainerCreationTest.java    From testcontainers-java with MIT License 5 votes vote down vote up
@Test @Ignore
public void testCreationOfManyContainers() {
    for (int i = 0; i < 50; i++) {
        BrowserWebDriverContainer container = new BrowserWebDriverContainer()
                .withCapabilities(new ChromeOptions())
                .withRecordingMode(BrowserWebDriverContainer.VncRecordingMode.RECORD_FAILING, new File("build"));

        container.start();
        RemoteWebDriver driver = container.getWebDriver();

        driver.get("http://www.google.com");

        container.stop();
    }
}
 
Example 11
Source File: DockerVncMixedJupiterTest.java    From selenium-jupiter with Apache License 2.0 5 votes vote down vote up
@Test
public void testHtmlVnc(
        @DockerBrowser(type = CHROME) RemoteWebDriver driver1,
        @DockerBrowser(type = FIREFOX) RemoteWebDriver driver2)
        throws InterruptedException {
    driver1.get("https://bonigarcia.github.io/selenium-jupiter/");
    driver2.get("https://bonigarcia.github.io/selenium-jupiter/");

    assertThat(driver1.getTitle(),
            containsString("JUnit 5 extension for Selenium"));
    assertThat(driver2.getTitle(),
            containsString("JUnit 5 extension for Selenium"));

    // Thread.sleep(50000);
}
 
Example 12
Source File: RemoteWebDriverTest.java    From mastering-junit5 with Apache License 2.0 5 votes vote down vote up
@Test
void testWithRemoteChrome(
        @DriverUrl("http://localhost:4444/wd/hub") @DriverCapabilities({
                "browserName=chrome",
                "version=59" }) RemoteWebDriver remoteChrome) {

    remoteChrome.get("https://bonigarcia.github.io/selenium-jupiter/");

    assertTrue(remoteChrome.getTitle().contains("JUnit 5 extension"));
}
 
Example 13
Source File: SampleHeadlessSauceTest.java    From demo-java with MIT License 5 votes vote down vote up
@Test
public void main() throws MalformedURLException {
    String sauceUserName = System.getenv("SAUCE_USERNAME");
    String sauceAccessKey = System.getenv("SAUCE_ACCESS_KEY");
    String URL = "https://ondemand.us-east-1.saucelabs.com/wd/hub";

    ChromeOptions chromeOpts = new ChromeOptions();
    chromeOpts.setExperimentalOption("w3c", true);

    MutableCapabilities sauceOptions = new MutableCapabilities();
    sauceOptions.setCapability("username", sauceUserName);
    sauceOptions.setCapability("accessKey", sauceAccessKey);
    sauceOptions.setCapability("seleniumVersion", "3.141.59");
    sauceOptions.setCapability("name", "headless-chrome-test-java");
    sauceOptions.setCapability("build", "Sample Headless Tests");

    MutableCapabilities caps = new MutableCapabilities();
    caps.setCapability("goog:chromeOptions", chromeOpts);
    caps.setCapability("browserName", "chrome");
    caps.setCapability("browserVersion", "latest");
    caps.setCapability("platformName", "Linux");
    caps.setCapability("sauce:options", sauceOptions);

    driver = new RemoteWebDriver(new URL(URL), caps);

    /* Goes to Sauce Lab's demo page and prints title */

    driver.get("https://www.saucedemo.com");
    System.out.println("title of page is: " + driver.getTitle());
    Assert.assertEquals(driver.getTitle(), "Swag Labs" );
}
 
Example 14
Source File: LinkedContainerTest.java    From testcontainers-java with MIT License 5 votes vote down vote up
@Test
public void testWebDriverToNginxContainerAccessViaContainerLink() {
    RemoteWebDriver driver = chrome.getWebDriver();

    driver.get("http://nginx/");

    assertEquals("Using selenium, an HTTP GET from the nginx server returns the index.html from the custom content directory", "This worked", driver.findElement(By.tagName("body")).getText());
}
 
Example 15
Source File: BaseWebDriverContainerTest.java    From testcontainers-java with MIT License 5 votes vote down vote up
protected static void doSimpleExplore(BrowserWebDriverContainer rule) {
    RemoteWebDriver driver = setupDriverFromRule(rule);
    driver.get("http://en.wikipedia.org/wiki/Randomness");

    // Oh! The irony!
    assertTrue("Randomness' description has the word 'pattern'", driver.findElementByPartialLinkText("pattern").isDisplayed());
}
 
Example 16
Source File: SauceLabsJupiterTest.java    From selenium-jupiter with Apache License 2.0 4 votes vote down vote up
@Test
void testWithSaucelabs(RemoteWebDriver driver) {
    driver.get("https://bonigarcia.github.io/selenium-jupiter/");
    assertThat(driver.getTitle(),
            containsString("JUnit 5 extension for Selenium"));
}
 
Example 17
Source File: SeleniumEphemeralTest.java    From ephemerals with MIT License 4 votes vote down vote up
@Test
public void test() {
    RemoteWebDriver remoteWebDriver = seleniumResource.get();
    remoteWebDriver.get("http://yahoo.com");
    Assert.assertNotNull(remoteWebDriver.findElementById("uh-logo"));
}
 
Example 18
Source File: OrderedMultipleJupiterTest.java    From selenium-jupiter with Apache License 2.0 4 votes vote down vote up
private void step1(RemoteWebDriver driver) {
    driver.get("https://bonigarcia.github.io/selenium-jupiter/");
    assertThat(driver.getTitle(),
            containsString("JUnit 5 extension for Selenium"));
}
 
Example 19
Source File: SearchTest.java    From Selenium-WebDriver-3-Practical-Guide-Second-Edition with MIT License 4 votes vote down vote up
@BeforeMethod
public void setup() throws MalformedURLException {

    DesiredCapabilities caps = new DesiredCapabilities();

    // for Google Chrome

    caps.setBrowserName("chrome");
    caps.setPlatform(Platform.MAC);

    // for Mozilla Firefox

    //caps.setBrowserName("firefox");
    //caps.setCapability("marionette", true);

    // for IE

    //caps.setBrowserName("internet explorer");

    driver = new RemoteWebDriver(new URL("http://192.168.0.101:1111/wd/hub"), caps);
    driver.get("http://demo-store.seleniumacademy.com/");

}
 
Example 20
Source File: SearchTest.java    From Selenium-WebDriver-3-Practical-Guide-Second-Edition with MIT License 3 votes vote down vote up
@BeforeMethod
public void setup() throws MalformedURLException {

    DesiredCapabilities caps = new DesiredCapabilities();

    /*
     for Google Chrome
    */

    caps.setBrowserName("chrome");

    /*
         for Mozilla Firefox
    */

    //caps.setBrowserName("firefox");
    //caps.setCapability("marionette", true);

    /*
        for IE
     */

    //caps.setBrowserName("internet explorer");

    driver = new RemoteWebDriver(new URL("http://127.0.0.1:4444/wd/hub"), caps);
    driver.get("http://demo-store.seleniumacademy.com/");

}