【问题标题】:Selenium automation test on Windows Server 2012 R2 using local host使用本地主机在 Windows Server 2012 R2 上进行 Selenium 自动化测试
【发布时间】:2018-07-25 23:18:33
【问题描述】:

我正在尝试在使用 Windows Server 2012 R2 的 Amazon active Workspace 上开发自动化测试。我正在使用localhost:8002 在本地机器上执行此操作。机器上没有互联网接入。到目前为止,我有以下代码:

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 Server 2012 R2',os.arch:'amd64',os.version:'6.3',java.version: '1.8.0_171'

任何帮助将不胜感激。

【问题讨论】:

    标签: java


    【解决方案1】:

    只是为了更新我的问题。我能够通过将 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();
        }
    }
    

    }

    查看以下链接进一步了解

    Unable to launch IE browser in selenium webdriver

    【讨论】:

      猜你喜欢
      • 2016-05-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-07
      • 1970-01-01
      • 2012-09-27
      • 1970-01-01
      • 2020-08-19
      相关资源
      最近更新 更多