package operators;

import operators.base.Operator;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.phantomjs.PhantomJSDriverService;
import org.openqa.selenium.remote.DesiredCapabilities;
import util.Credentials;

import java.util.concurrent.TimeUnit;

/**
 * Created by eunderhi on 09/09/15.
 */
public class SetUpOperator extends Operator {

    private Credentials creds = new Credentials();
    private static final int LOAD_WAIT_TIME = 5;
    private String phantomjsPath = creds.getPhantomjsPath();

    public void setUp() {

        DesiredCapabilities caps = new DesiredCapabilities();
        caps.setCapability("takesScreenshot", true);
        caps.setCapability(
                PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,
                phantomjsPath
        );
        String[] phantomArgs = new  String[] {
                "--webdriver-loglevel=NONE",
                "--ssl-protocol=any"
        };
        caps.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, phantomArgs);
        //driver = new PhantomJSDriver();
        driver = new FirefoxDriver();
        driver.manage().timeouts().implicitlyWait(LOAD_WAIT_TIME, TimeUnit.SECONDS);
        driver.manage().window().setSize(new Dimension(1024, 768));
        loginOrGoToBaseURL();
    }

    private void loginOrGoToBaseURL() {
        if(creds.hasLoginURL()) {
            String username = creds.getUsername();
            String password = creds.getPassword();
            String loginUrl = creds.getLoginURL();
            new LoginOperator().login(loginUrl, username, password);
        }
        else {
            String baseURL = creds.getBaseURL();
            driver.get(baseURL);
        }
    }

}

@@ -509,621 +509,34 @@
  5;%0A
-    private String phantomjsPath = creds.getPhantomjsPath();%0A%0A    public void setUp() %7B%0A%0A        DesiredCapabilities caps = new DesiredCapabilities();%0A        caps.setCapability(%22takesScreenshot%22, true);%0A        caps.setCapability(%0A                PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,%0A                phantomjsPath%0A        );%0A        String%5B%5D phantomArgs = new  String%5B%5D %7B%0A                %22--webdriver-loglevel=NONE%22,%0A                %22--ssl-protocol=any%22%0A        %7D;%0A        caps.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, phantomArgs);%0A        //driver = new PhantomJSDriver();
+%0A    public void setUp() %7B
 %0A   

Remove old phantomjs configuration