I'm trying to set up a UI testing framework on a project using Selenium in JUnit tests inside of Testcontainers, using IntelliJ IDE to develop. I am using OpenJDK 12.0.1
I have the most basic test that I can think of, but I keep getting Null Pointer Exceptions when trying to get ANY website (wikipedia, google, etc.)
Am I missing something crucial here?
Here is the test that I have set up:
public class SimpleTest {
@Rule
public BrowserWebDriverContainer chrome = new BrowserWebDriverContainer()
.withCapabilities(new ChromeOptions());
@Test
public void simplePlainSeleniumTest() {
RemoteWebDriver driver = chrome.getWebDriver();
driver.get("https://google.com");
assertTrue("This should always pass", true);
}
}
In my gradle file I am importing the following:
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.141.59'
compile group: 'org.seleniumhq.selenium', name: 'selenium-remote-driver', version: '3.141.59'
testCompile group: 'org.testcontainers', name: 'selenium', version: '1.11.3'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.2.0'
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.2.0'
test {
useJUnitPlatform()
}
I have no special settings in my testcontainers.properties file
If I am understanding all of the examples I have seen, this should be:
- Opening the test inside a docker container via testcontainers.
- Creating a driver for Chrome inside of that container.
- Navigating to the given website (in the example above, google.com)
- Passing, because true = true
But I run into the following error no matter what I am changing code-wise:
selenium.SimpleTest > simplePlainSeleniumTest() FAILED
java.lang.NullPointerException at SimpleTest.java:34
Line 34 is: driver.get("https://google.com");