Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use OperaChromiumDriver for opera version >12.X

I understand that to work on opera versions > 12.X, Operachromiumdriver has been developed. At the same time I couldn't get this to work. I downloaded the windows version of operachromiumdriver.exe from https://github.com/operasoftware/operachromiumdriver/releases but to no avail. Can someone help me with this . Please tell me if my understanding is right.

Thanks

like image 948
dev Avatar asked Jan 09 '23 07:01

dev


2 Answers

I have found the solution running opera 25+ using OperaChromiumDriver.exe.

  1. Install Opera 25+ (I installed Opera 25)
  2. Download OperaChromiumDriver https://github.com/operasoftware/operachromiumdriver/releases
  3. Extract the zip file to a location on the computer
  4. Use the following code to open Opera

    System.setProperty("webdriver.chrome.driver", "C:/Users/user/Downloads/operadriver-0.1.0-win32/operadriver-0.1.0-win32.exe");
    WebDriver driver = new ChromeDriver();
    driver.get("https://www.google.com");
    driver.findElement(By.name("q")).sendKeys("Selenium");
    

I have used new ChromeDriver(). This will start Opera since we are using OperaChromiumDriver. I think this is because the new Opera is based on Chromium and OperaChromiumDriver is a WebDriver implementation derived from ChromeDriver [See https://github.com/operasoftware/operachromiumdriver].

Hope this helps you.

like image 94
Sighil Avatar answered Feb 14 '23 18:02

Sighil


OperaChromiumDriver now works with Opera 26+ but only with a remote instance so far... Download and launch the appropriate binary from

OperaChromiumDriver Binary Releases

They have examples for Desktop versions in python but here's what worked for me in Java. Many ChromeOptions do not work though it says they should... you will have to test to know for sure but the setBinary does work.

DesiredCapabilities capabilities = DesiredCapabilities.opera();

ChromeOptions options = new ChromeOptions();
options.setBinary("/path/to/opera");

capabilities.setCapability(ChromeOptions.CAPABILITY, options);

driver = new RemoteWebDriver(new URL("http://127.0.0.1:9515"),capabilities);
like image 40
Lukus Avatar answered Feb 14 '23 16:02

Lukus