/*
 * (C) Copyright 2015 Boni Garcia (http://bonigarcia.github.io/)
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser General Public License
 * (LGPL) version 2.1 which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/lgpl-2.1.html
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 */
package io.github.bonigarcia.wdm.test;

import static java.lang.Boolean.parseBoolean;
import static java.lang.System.getProperty;
import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS;
import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeTrue;
import static org.openqa.selenium.opera.OperaOptions.CAPABILITY;
import static org.openqa.selenium.remote.DesiredCapabilities.operaBlink;

import java.io.File;

import org.junit.Before;
import org.junit.BeforeClass;
import org.openqa.selenium.opera.OperaDriver;
import org.openqa.selenium.opera.OperaOptions;
import org.openqa.selenium.remote.DesiredCapabilities;

import io.github.bonigarcia.wdm.OperaDriverManager;
import io.github.bonigarcia.wdm.base.BaseBrowserTst;

/**
 * Test with Opera browser.
 *
 * @author Boni Garcia (boni.gg@gmail.com)
 * @since 1.0.0
 */
public class OperaTest extends BaseBrowserTst {

    @BeforeClass
    public static void setupClass() {
        assumeFalse(parseBoolean(getProperty("headlessEnvironment")));
        OperaDriverManager.getInstance().setup();
    }

    @Before
    public void setupTest() {
        DesiredCapabilities capabilities = operaBlink();
        File operaBinary = null;
        if (IS_OS_WINDOWS) {
            operaBinary = new File("C:\\Program Files\\Opera\\launcher.exe");
        } else {
            operaBinary = new File("/usr/bin/opera");
        }

        assumeTrue(operaBinary != null && operaBinary.exists());
        OperaOptions options = new OperaOptions();
        options.setBinary(operaBinary);
        capabilities.setCapability(CAPABILITY, options);

        driver = new OperaDriver(capabilities);
    }

}

@@ -1727,65 +1727,8 @@
 ) %7B%0A
-        DesiredCapabilities capabilities = operaBlink();%0A
     
@@ -1751,15 +1751,8 @@
 nary
- = null
 ;%0A  
@@ -1933,25 +1933,24 @@
 ;%0A        %7D%0A
-%0A
         assu
@@ -1971,31 +1971,8 @@
 nary
- != null && operaBinary
 .exi
@@ -1975,24 +1975,25 @@
 .exists());%0A
+%0A
         Oper
@@ -2071,16 +2071,73 @@
 inary);%0A
+        DesiredCapabilities capabilities = operaBlink();%0A
         
@@ -2185,17 +2185,16 @@
 tions);%0A
-%0A
         

Improve test for Opera browser