Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/373.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用本地主机在Windows Server 2012 R2上进行Selenium自动化测试_Java - Fatal编程技术网

Java 使用本地主机在Windows Server 2012 R2上进行Selenium自动化测试

Java 使用本地主机在Windows Server 2012 R2上进行Selenium自动化测试,java,Java,我正在尝试在Amazon active Workspace上开发自动化测试,它使用Windows Server 2012 R2。我正在本地计算机上使用localhost:8002进行此操作。计算机上没有internet访问权限。到目前为止,我有以下代码: package activeworkspaceprog; import java.net.URL; import java.util.concurrent.TimeUnit; import org.openqa.selenium.Javasc

我正在尝试在Amazon active Workspace上开发自动化测试,它使用Windows Server 2012 R2。我正在本地计算机上使用
localhost:8002
进行此操作。计算机上没有internet访问权限。到目前为止,我有以下代码:

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. 
错误:

org.openqa.selenium.remote.UnreachableBrowserException:无法访问 开始新的会话。可能的原因是远程服务器的地址无效 服务器或浏览器启动失败。生成信息:版本:“3.13.0”, 修订版:“2f0d292”,时间:“2018-06-25T15:32:19.891Z”系统信息: 主机:“WIN-K0E8GV2L510”,ip:“10.0.1.252”,os.name:“Windows服务器” 2012 R2',os.arch:'amd64',os.version:'6.3',java.version: “1.8.0_171”


任何帮助都将不胜感激

只是想更新一下我的问题。我可以通过将internet explorer的安全设置设置为相同的级别来解决这个问题。默认情况下,“所有区域”安全设置为不同级别。已为Internet、本地intranet和受限站点启用保护模式。但是,不为受信任的站点启用此选项。因此,这些不同级别的安全设置会混淆浏览器,最终引发错误。因此,请确保它们要么对所有对象启用,要么对所有对象禁用,以便将它们设置为同一级别。仅以下代码就足以调用浏览器:

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();
    }
}
}

查看以下链接以进一步了解