Skip to content

Commit 0c231ed

Browse files
bahtiyarkabaCalamarBicefalo
authored andcommitted
webdriver test added
1 parent 2e125a0 commit 0c231ed

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

‎testing-modules/test-containers/pom.xml‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,21 @@
8383
<artifactId>postgresql </artifactId>
8484
<version>1.7.2</version>
8585
</dependency>
86+
<dependency>
87+
<groupId>org.testcontainers</groupId>
88+
<artifactId>selenium </artifactId>
89+
<version>1.7.2</version>
90+
</dependency>
8691
<dependency>
8792
<groupId>org.postgresql</groupId>
8893
<artifactId>postgresql</artifactId>
8994
<version>42.2.2</version>
9095
</dependency>
96+
<dependency>
97+
<groupId>org.seleniumhq.selenium</groupId>
98+
<artifactId>selenium-remote-driver</artifactId>
99+
<version>3.12.0</version>
100+
</dependency>
91101

92102
</dependencies>
93103

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.baeldung.testconainers;
2+
3+
import static org.junit.Assert.assertEquals;
4+
5+
import org.junit.ClassRule;
6+
import org.junit.Rule;
7+
import org.junit.Test;
8+
import org.openqa.selenium.By;
9+
import org.openqa.selenium.remote.DesiredCapabilities;
10+
import org.openqa.selenium.remote.RemoteWebDriver;
11+
import org.testcontainers.DockerClientFactory;
12+
import org.testcontainers.containers.BrowserWebDriverContainer;
13+
import org.testcontainers.containers.GenericContainer;
14+
15+
import net.codestory.http.WebServer;
16+
17+
public class WebDriverContainerTests {
18+
@Rule
19+
public BrowserWebDriverContainer chrome = new BrowserWebDriverContainer().withDesiredCapabilities(DesiredCapabilities.chrome());
20+
21+
@Test
22+
public void when() {
23+
RemoteWebDriver driver = chrome.getWebDriver();
24+
driver.get("https://saucelabs.com/test/guinea-pig");
25+
String heading = driver.findElement(By.xpath("/html/body/h1"))
26+
.getText();
27+
assertEquals("This page is a Selenium sandbox", heading);
28+
}
29+
}

0 commit comments

Comments
 (0)