Skip to content

Commit 85711c1

Browse files
committed
Include support for Chromium (checking binary from Chrome options)
1 parent 6a0438d commit 85711c1

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

src/main/java/io/github/bonigarcia/seljup/handler/ChromeDriverHandler.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package io.github.bonigarcia.seljup.handler;
1818

1919
import static java.util.Arrays.stream;
20+
import static org.openqa.selenium.chrome.ChromeOptions.CAPABILITY;
2021

2122
import java.io.IOException;
2223
import java.lang.reflect.Parameter;
@@ -34,6 +35,7 @@
3435
import io.github.bonigarcia.seljup.Extensions;
3536
import io.github.bonigarcia.seljup.Options;
3637
import io.github.bonigarcia.seljup.config.Config;
38+
import io.github.bonigarcia.wdm.WebDriverManager;
3739

3840
/**
3941
* Resolver for ChromeDriver.
@@ -62,6 +64,11 @@ public void resolve() {
6264
ChromeOptions chromeOptions = (ChromeOptions) getOptions(parameter,
6365
testInstance);
6466

67+
if (chromeOptions.asMap().get(CAPABILITY).toString().toLowerCase()
68+
.contains("chromium")) {
69+
WebDriverManager.chromiumdriver().setup();
70+
}
71+
6572
if (capabilities.isPresent()) {
6673
chromeOptions.merge(capabilities.get());
6774
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* (C) Copyright 2020 Boni Garcia (http://bonigarcia.github.io/)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
package io.github.bonigarcia.seljup.test.basic;
18+
19+
import static org.apache.commons.lang3.SystemUtils.IS_OS_MAC;
20+
import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS;
21+
import static org.hamcrest.CoreMatchers.containsString;
22+
import static org.hamcrest.MatcherAssert.assertThat;
23+
24+
import org.junit.jupiter.api.Disabled;
25+
import org.junit.jupiter.api.Test;
26+
import org.junit.jupiter.api.extension.ExtendWith;
27+
import org.openqa.selenium.chrome.ChromeDriver;
28+
import org.openqa.selenium.chrome.ChromeOptions;
29+
30+
import io.github.bonigarcia.seljup.Options;
31+
import io.github.bonigarcia.seljup.SeleniumExtension;
32+
33+
@ExtendWith(SeleniumExtension.class)
34+
class ChromiumJupiterTest {
35+
36+
@Options
37+
ChromeOptions options = new ChromeOptions();
38+
{
39+
String chromium;
40+
if (IS_OS_WINDOWS) {
41+
String localAppDat = System.getenv("LOCALAPPDATA")
42+
.replaceAll("\\\\", "\\\\\\\\");
43+
chromium = localAppDat + "\\Chromium\\Application\\chrome.exe";
44+
} else {
45+
chromium = IS_OS_MAC
46+
? "/Applications/Chromium.app/Contents/MacOS/Chromium"
47+
: "/usr/bin/chromium-browser";
48+
}
49+
options.setBinary(chromium);
50+
}
51+
52+
@Disabled
53+
@Test
54+
void testChromium(ChromeDriver driver) {
55+
driver.get("https://bonigarcia.github.io/selenium-jupiter/");
56+
assertThat(driver.getTitle(),
57+
containsString("JUnit 5 extension for Selenium"));
58+
}
59+
60+
}

0 commit comments

Comments
 (0)