webdriver test added

This commit is contained in:
Bahtiyar Kaba 2018-06-05 09:23:56 +03:00 committed by José Carlos Valero Sánchez
parent 2e125a0da3
commit 0c231ed0e6
2 changed files with 39 additions and 0 deletions

View File

@ -83,11 +83,21 @@
<artifactId>postgresql </artifactId> <artifactId>postgresql </artifactId>
<version>1.7.2</version> <version>1.7.2</version>
</dependency> </dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>selenium </artifactId>
<version>1.7.2</version>
</dependency>
<dependency> <dependency>
<groupId>org.postgresql</groupId> <groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId> <artifactId>postgresql</artifactId>
<version>42.2.2</version> <version>42.2.2</version>
</dependency> </dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
<version>3.12.0</version>
</dependency>
</dependencies> </dependencies>

View File

@ -0,0 +1,29 @@
package com.baeldung.testconainers;
import static org.junit.Assert.assertEquals;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testcontainers.DockerClientFactory;
import org.testcontainers.containers.BrowserWebDriverContainer;
import org.testcontainers.containers.GenericContainer;
import net.codestory.http.WebServer;
public class WebDriverContainerTests {
@Rule
public BrowserWebDriverContainer chrome = new BrowserWebDriverContainer().withDesiredCapabilities(DesiredCapabilities.chrome());
@Test
public void when() {
RemoteWebDriver driver = chrome.getWebDriver();
driver.get("https://saucelabs.com/test/guinea-pig");
String heading = driver.findElement(By.xpath("/html/body/h1"))
.getText();
assertEquals("This page is a Selenium sandbox", heading);
}
}