javaseleniumoperadriver

Selenium test fails to start using operadriver


My cross browser test fails only for opera driver since it is working with all the other drivers (chrome, firefox and ie).

Here is the java code.

System.setProperty("webdriver.opera.driver", "...\\operadriver.exe");
driver = new OperaDriver(); 

Here is the testng class.

  <test name="OperaTestCases">  
      <parameter name="browser" value="opera"/>  
      <classes> 
         <class name="crossBrowser.Test"/> 
      </classes> 
  </test>

browser is opening but nothing is happening. and test fails. :)


Solution

  • I suggest you to install Opera 38 and add following code instead your java code.

    System.setProperty("webdriver.chrome.driver", "...\\operadriver.exe");
    driver = new ChromeDriver();
    

    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. :)