package com.sdl.selenium.utils.browsers;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.DesiredCapabilities;

import java.io.IOException;

public class IExplorerConfigReader extends AbstractBrowserConfigReader {

    private static final String DEFAULT_CONFIG = ""+
            "\n browser=iexplore" +
            "\n browser.driver.path=src\\\\test\\\\resources\\\\drivers\\\\IEDriverServer.exe";

    public IExplorerConfigReader() {
        this(null);
    }

    public IExplorerConfigReader(String resourcePath) {
        super(DEFAULT_CONFIG, resourcePath);
    }

    @Override
    public WebDriver createDriver() throws IOException {
        DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
        ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
        String driverPath = getProperty("browser.driver.path");
        if (!"".equals(driverPath)) {
            System.setProperty("webdriver.ie.driver", driverPath);
        }
        return new InternetExplorerDriver(ieCapabilities);
    }

    @Override
    public boolean isSilentDownload() {
        return !"".equals(getProperty("browser.download.dir"));
    }

    @Override
    public String getDownloadPath() {
        //http://stackoverflow.com/questions/18510965/how-to-set-internetexplorerdriver-download-directory
        return "";
    }
}

@@ -165,35 +165,145 @@
 .remote.
-DesiredCapabilities
+CapabilityType;%0D%0Aimport org.openqa.selenium.remote.DesiredCapabilities;%0D%0Aimport org.slf4j.Logger;%0D%0Aimport org.slf4j.LoggerFactory
 ;%0D%0A%0D%0Aimp
@@ -327,16 +327,39 @@
 eption;%0D
+%0Aimport java.util.Map;%0D
 %0A%0D%0Apubli
@@ -426,16 +426,112 @@
 eader %7B%0D
+%0A    private static final Logger LOGGER = LoggerFactory.getLogger(IExplorerConfigReader.class);%0D
 %0A%0D%0A    p
@@ -576,16 +576,17 @@
 FIG = %22%22
+ 
 +%0D%0A     
@@ -1169,24 +1169,102 @@
 NS, true);%0D%0A
+        ieCapabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);%0D%0A
         Stri
@@ -1434,16 +1434,47 @@
      %7D%0D%0A
+        //setExtraProperty();%0D%0A
         
@@ -1852,12 +1852,369 @@
 %0D%0A    %7D%0D
+%0A%0D%0A    private void setExtraProperty() %7B%0D%0A        for (Map.Entry%3CObject, Object%3E entry : entrySet()) %7B%0D%0A            String key = (String) entry.getKey();%0D%0A            String value = (String) entry.getValue();%0D%0A            overWriteWebLocatorConfig(key, value);%0D%0A        %7D%0D%0A        LOGGER.info(%22The properties was load with success: %7B%7D%22, toString());%0D%0A    %7D%0D
 %0A%7D%0D%0A

add ieCapabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);