Skip to content

Commit b8a60c8

Browse files
committed
[java] Run Chrome headless if on GitHub Actions
1 parent 937e8f9 commit b8a60c8

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

java/client/test/org/openqa/selenium/chrome/ChromeOptionsFunctionalTest.java

+14-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.openqa.selenium.build.InProject;
3030
import org.openqa.selenium.testing.JUnit4TestBase;
3131
import org.openqa.selenium.testing.NeedsLocalEnvironment;
32+
import org.openqa.selenium.testing.TestUtilities;
3233

3334
import java.io.IOException;
3435
import java.nio.file.Files;
@@ -52,6 +53,9 @@ public void tearDown() {
5253
@Test
5354
public void canStartChromeWithCustomOptions() {
5455
ChromeOptions options = new ChromeOptions();
56+
if (TestUtilities.isOnTravis()) {
57+
options.setHeadless(true);
58+
}
5559
options.addArguments("user-agent=foo;bar");
5660
driver = new ChromeDriver(options);
5761

@@ -74,6 +78,9 @@ public void optionsStayEqualAfterSerialization() {
7478
@Test
7579
public void canSetAcceptInsecureCerts() {
7680
ChromeOptions options = new ChromeOptions();
81+
if (TestUtilities.isOnTravis()) {
82+
options.setHeadless(true);
83+
}
7784
options.setAcceptInsecureCerts(true);
7885
driver = new ChromeDriver(options);
7986

@@ -84,6 +91,9 @@ public void canSetAcceptInsecureCerts() {
8491
@Test
8592
public void canAddExtensionFromFile() {
8693
ChromeOptions options = new ChromeOptions();
94+
if (TestUtilities.isOnTravis()) {
95+
options.setHeadless(true);
96+
}
8797
options.addExtensions(InProject.locate(EXT_PATH).toFile());
8898
driver = new ChromeDriver(options);
8999

@@ -100,8 +110,11 @@ public void canAddExtensionFromFile() {
100110
@Test
101111
public void canAddExtensionFromStringEncodedInBase64() throws IOException {
102112
ChromeOptions options = new ChromeOptions();
113+
if (TestUtilities.isOnTravis()) {
114+
options.setHeadless(true);
115+
}
103116
options.addEncodedExtensions(Base64.getEncoder().encodeToString(
104-
Files.readAllBytes(InProject.locate(EXT_PATH))));
117+
Files.readAllBytes(InProject.locate(EXT_PATH))));
105118
driver = new ChromeDriver(options);
106119

107120
driver.get(pages.clicksPage);

0 commit comments

Comments
 (0)