Skip to content

Commit

Permalink
Support Opera and Yandex browsers (#134)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
mialeska authored Jan 24, 2024
1 parent ca87db9 commit 165e135
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import aquality.selenium.core.localization.ILocalizedLogger;
import aquality.selenium.core.utilities.IActionRetrier;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeDriverService;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.edge.EdgeOptions;
Expand Down Expand Up @@ -32,9 +33,13 @@ protected RemoteWebDriver getDriver() {
IDriverSettings driverSettings = browserProfile.getDriverSettings();
switch (browserName) {
case CHROME:
case YANDEX:
driver = new ChromeDriver((ChromeOptions) driverSettings.getDriverOptions());
break;
case YANDEX:
case OPERA:
driver = new ChromeDriver(new ChromeDriverService.Builder().withBuildCheckDisabled(true).build(),
(ChromeOptions) driverSettings.getDriverOptions());
break;
case FIREFOX:
driver = new FirefoxDriver((FirefoxOptions) driverSettings.getDriverOptions());
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public IDriverSettings getDriverSettings() {
case SAFARI:
driverSettings = new SafariSettings(settingsFile);
break;
case OPERA:
driverSettings = new OperaSettings(settingsFile);
break;
case YANDEX:
driverSettings = new YandexSettings(settingsFile);
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package aquality.selenium.configuration.driversettings;

import aquality.selenium.browser.BrowserName;
import aquality.selenium.core.utilities.ISettingsFile;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.AbstractDriverOptions;

public class OperaSettings extends ChromeSettings {
private static final String DEFAULT_BINARY_LOCATION = "%USERPROFILE%\\AppData\\Local\\Programs\\Opera\\launcher.exe";
public OperaSettings(ISettingsFile settingsFile) {
super(settingsFile);
}

@Override
public AbstractDriverOptions<?> getDriverOptions() {
ChromeOptions options = (ChromeOptions) super.getDriverOptions();
options.setExperimentalOption("w3c", true);
options.setBinary(getBinaryLocation(DEFAULT_BINARY_LOCATION));
return options;
}

@Override
public BrowserName getBrowserName() {
return BrowserName.OPERA;
}
}
15 changes: 15 additions & 0 deletions src/main/resources/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,21 @@
"safari": {
"downloadDir": "/Users/username/Downloads"
},
"opera": {
"binaryLocation": "%USERPROFILE%\\AppData\\Local\\Programs\\Opera\\launcher.exe",
"capabilities": {
"unhandledPromptBehavior": "ignore"
},
"options": {
"intl.accept_languages": "en",
"safebrowsing.enabled": "true",
"profile.default_content_settings.popups": "0",
"disable-popup-blocking": "true",
"download.prompt_for_download": "false",
"download.default_directory": "./downloads"
},
"startArguments": [ "--remote-debugging-port=9222", "--no-sandbox", "--disable-dev-shm-usage" ]
},
"yandex": {
"binaryLocation": "%USERPROFILE%\\AppData\\Local\\Yandex\\YandexBrowser\\Application\\browser.exe",
"capabilities": {
Expand Down
15 changes: 15 additions & 0 deletions src/test/resources/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,21 @@
"safari": {
"downloadDir": "/Users/username/Downloads"
},
"opera": {
"binaryLocation": "%USERPROFILE%\\AppData\\Local\\Programs\\Opera\\launcher.exe",
"capabilities": {
"unhandledPromptBehavior": "ignore"
},
"options": {
"intl.accept_languages": "en",
"safebrowsing.enabled": "true",
"profile.default_content_settings.popups": "0",
"disable-popup-blocking": "true",
"download.prompt_for_download": "false",
"download.default_directory": "./downloads"
},
"startArguments": [ "--remote-debugging-port=9222", "--no-sandbox", "--disable-dev-shm-usage" ]
},
"yandex": {
"binaryLocation": "%USERPROFILE%\\AppData\\Local\\Yandex\\YandexBrowser\\Application\\browser.exe",
"capabilities": {
Expand Down

0 comments on commit 165e135

Please sign in to comment.