简体   繁体   中英

Selenium automation test on Windows Server 2012 R2 using local host

I am trying to develop automation test on Amazon active Workspace, which uses Windows Server 2012 R2. I am doing it on local machine using localhost:8002 . There is no internet access on the machine. So far I have following code:

package activeworkspaceprog;

import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

public class ActiveWorkspaceProg {
    WebDriver driver;
    JavascriptExecutor jse;
    public static void main(String[] args)
    {
        ActiveWorkspaceProg run = new ActiveWorkspaceProg();
        run.invokeBrowser();   
    }
    public void invokeBrowser()
    {
        try
        {
             System.setProperty("webdriver.ie.driver","C:\\Users\\Administrator\\Desktop\\IEDriverServer.exe");
             DesiredCapabilities capability = DesiredCapabilities.internetExplorer();
             driver = new RemoteWebDriver(
                      new URL("https://WIN-K0E8GV2L510:8002@hub-cloud.browserstack.com/wd/hub")
                     ,capability);
             capability.setCapability(InternetExplorerDriver.
                     INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
             driver = new InternetExplorerDriver();
             driver.manage().window().maximize();
             driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
             driver.get("http://localhost:8002/awc/");           
        } 
        catch( Exception e)
        {
            e.printStackTrace();
        }
    }
}

    I am using Selenium Standalone Server-3.13.0 jar and IEDriverServer.exe (version - 3.13.0.0) as my WebDriver.

    But, I am just getting the following error,and I am stuck. 

Error:

org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. Build info: version: '3.13.0', revision: '2f0d292', time: '2018-06-25T15:32:19.891Z' System info: host: 'WIN-K0E8GV2L510', ip: '10.0.1.252', os.name: 'Windows Server 2012 R2', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_171'

Any help would be appreciated.

Just to give an update on my question. I was able to solve the issue by setting the security setting of the internet explorer to be at the same level. By default, the all zones security is set at different levels. The protected mode is enabled for Internet, Local intranet and Restricted sites. However, it is not enabled for Trusted sites. So, these different levels of security setting confuses the browser, which ends up throwing an error. So, make sure they are either enabled for all or disabled for all, so that they are set at the same level. Just following code should be enough to invoke the browser:

WebDriver driver;
JavascriptExecutor jse;
public static void main(String[] args)
{
    ActiveWorkspaceProg run = new ActiveWorkspaceProg();
    run.invokeBrowser();   
}
public void invokeBrowser()
{
    try
    {
        System.setProperty("webdriver.ie.driver","C:\\Users\\Administrator\\Desktop\\IEDriverServer.exe");
        DesiredCapabilities capability = DesiredCapabilities.internetExplorer();
        capability.setCapability("ignoreZoomSetting", true);
        capability.setCapability(InternetExplorerDriver.
            INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
        driver = new InternetExplorerDriver();
        driver.manage().window().maximize();
        driver.manage().deleteAllCookies();
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
        driver.manage().timeouts().pageLoadTimeout(40, TimeUnit.SECONDS);
        driver.get("http://localhost:8002/awc/"); 
    } 
    catch( Exception e)
    {
        e.printStackTrace();
    }
}

}

Look the following link for further understanding

Unable to launch IE browser in selenium webdriver

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM