Skip to content

Commit

Permalink
Enhance ecreate method for operadriver
Browse files Browse the repository at this point in the history
  • Loading branch information
bonigarcia committed Apr 8, 2022
1 parent d8e13dd commit 3b1b18b
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.nio.file.Path;
import java.util.List;
import java.util.Optional;

import org.openqa.selenium.Capabilities;
import org.openqa.selenium.opera.OperaOptions;
import org.openqa.selenium.chrome.ChromeOptions;

import io.github.bonigarcia.wdm.WebDriverManager;
import io.github.bonigarcia.wdm.config.DriverManagerType;
Expand All @@ -39,7 +40,6 @@
* @author Boni Garcia
* @since 1.0.0
*/
@SuppressWarnings("deprecation")
public class OperaDriverManager extends WebDriverManager {

@Override
Expand Down Expand Up @@ -176,7 +176,12 @@ protected Optional<String> getDriverVersionFromRepository(

@Override
protected Capabilities getCapabilities() {
return new OperaOptions();
ChromeOptions options = new ChromeOptions();
Optional<Path> browserPath = getBrowserPath();
if (browserPath.isPresent()) {
options.setBinary(browserPath.get().toFile());
}
return options;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* (C) Copyright 2022 Boni Garcia (https://bonigarcia.github.io/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.github.bonigarcia.wdm.test.opera;

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.WebDriver;

import io.github.bonigarcia.wdm.WebDriverManager;

class OperaCreateTest {

WebDriver driver;

@BeforeEach
void setupTest() {
driver = WebDriverManager.operadriver().create();
}

@AfterEach
void teardown() {
driver.quit();
}

@Test
void test() {
driver.get("https://bonigarcia.dev/selenium-webdriver-java/");
assertThat(driver.getTitle()).contains("Selenium WebDriver");
}

}

0 comments on commit 3b1b18b

Please sign in to comment.