Skip to content

Commit 165e135

Browse files
authored
Support Opera and Yandex browsers (#134)
- Add section to settings.json for Opera browser - Add specific OperaSettings with w3c workaround and binary location - Update LocalBrowserFactory to separate Opera and Yandex cases from Chrome. For them, use ChromeDriverService with disabled build check
1 parent ca87db9 commit 165e135

File tree

5 files changed

+65
-1
lines changed

5 files changed

+65
-1
lines changed

src/main/java/aquality/selenium/browser/LocalBrowserFactory.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import aquality.selenium.core.localization.ILocalizedLogger;
66
import aquality.selenium.core.utilities.IActionRetrier;
77
import org.openqa.selenium.chrome.ChromeDriver;
8+
import org.openqa.selenium.chrome.ChromeDriverService;
89
import org.openqa.selenium.chrome.ChromeOptions;
910
import org.openqa.selenium.edge.EdgeDriver;
1011
import org.openqa.selenium.edge.EdgeOptions;
@@ -32,9 +33,13 @@ protected RemoteWebDriver getDriver() {
3233
IDriverSettings driverSettings = browserProfile.getDriverSettings();
3334
switch (browserName) {
3435
case CHROME:
35-
case YANDEX:
3636
driver = new ChromeDriver((ChromeOptions) driverSettings.getDriverOptions());
3737
break;
38+
case YANDEX:
39+
case OPERA:
40+
driver = new ChromeDriver(new ChromeDriverService.Builder().withBuildCheckDisabled(true).build(),
41+
(ChromeOptions) driverSettings.getDriverOptions());
42+
break;
3843
case FIREFOX:
3944
driver = new FirefoxDriver((FirefoxOptions) driverSettings.getDriverOptions());
4045
break;

src/main/java/aquality/selenium/configuration/BrowserProfile.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ public IDriverSettings getDriverSettings() {
5252
case SAFARI:
5353
driverSettings = new SafariSettings(settingsFile);
5454
break;
55+
case OPERA:
56+
driverSettings = new OperaSettings(settingsFile);
57+
break;
5558
case YANDEX:
5659
driverSettings = new YandexSettings(settingsFile);
5760
break;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package aquality.selenium.configuration.driversettings;
2+
3+
import aquality.selenium.browser.BrowserName;
4+
import aquality.selenium.core.utilities.ISettingsFile;
5+
import org.openqa.selenium.chrome.ChromeOptions;
6+
import org.openqa.selenium.remote.AbstractDriverOptions;
7+
8+
public class OperaSettings extends ChromeSettings {
9+
private static final String DEFAULT_BINARY_LOCATION = "%USERPROFILE%\\AppData\\Local\\Programs\\Opera\\launcher.exe";
10+
public OperaSettings(ISettingsFile settingsFile) {
11+
super(settingsFile);
12+
}
13+
14+
@Override
15+
public AbstractDriverOptions<?> getDriverOptions() {
16+
ChromeOptions options = (ChromeOptions) super.getDriverOptions();
17+
options.setExperimentalOption("w3c", true);
18+
options.setBinary(getBinaryLocation(DEFAULT_BINARY_LOCATION));
19+
return options;
20+
}
21+
22+
@Override
23+
public BrowserName getBrowserName() {
24+
return BrowserName.OPERA;
25+
}
26+
}

src/main/resources/settings.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,21 @@
6666
"safari": {
6767
"downloadDir": "/Users/username/Downloads"
6868
},
69+
"opera": {
70+
"binaryLocation": "%USERPROFILE%\\AppData\\Local\\Programs\\Opera\\launcher.exe",
71+
"capabilities": {
72+
"unhandledPromptBehavior": "ignore"
73+
},
74+
"options": {
75+
"intl.accept_languages": "en",
76+
"safebrowsing.enabled": "true",
77+
"profile.default_content_settings.popups": "0",
78+
"disable-popup-blocking": "true",
79+
"download.prompt_for_download": "false",
80+
"download.default_directory": "./downloads"
81+
},
82+
"startArguments": [ "--remote-debugging-port=9222", "--no-sandbox", "--disable-dev-shm-usage" ]
83+
},
6984
"yandex": {
7085
"binaryLocation": "%USERPROFILE%\\AppData\\Local\\Yandex\\YandexBrowser\\Application\\browser.exe",
7186
"capabilities": {

src/test/resources/settings.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,21 @@
6565
"safari": {
6666
"downloadDir": "/Users/username/Downloads"
6767
},
68+
"opera": {
69+
"binaryLocation": "%USERPROFILE%\\AppData\\Local\\Programs\\Opera\\launcher.exe",
70+
"capabilities": {
71+
"unhandledPromptBehavior": "ignore"
72+
},
73+
"options": {
74+
"intl.accept_languages": "en",
75+
"safebrowsing.enabled": "true",
76+
"profile.default_content_settings.popups": "0",
77+
"disable-popup-blocking": "true",
78+
"download.prompt_for_download": "false",
79+
"download.default_directory": "./downloads"
80+
},
81+
"startArguments": [ "--remote-debugging-port=9222", "--no-sandbox", "--disable-dev-shm-usage" ]
82+
},
6883
"yandex": {
6984
"binaryLocation": "%USERPROFILE%\\AppData\\Local\\Yandex\\YandexBrowser\\Application\\browser.exe",
7085
"capabilities": {

0 commit comments

Comments
 (0)