简体   繁体   English

使用本地主机的Windows Server 2012 R2上的硒自动化测试

[英]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. 我正在尝试在使用Windows Server 2012 R2的Amazon active Workspace上开发自动化测试。 I am doing it on local machine using localhost:8002 . 我正在使用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. org.openqa.selenium.remote.UnreachableBrowserException:无法启动新的会话。 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' 构建信息:版本:'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'

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. 通过将Internet Explorer的安全设置设置为相同级别,我能够解决此问题。 By default, the all zones security is set at different levels. 默认情况下,所有区域安全性均设置为不同级别。 The protected mode is enabled for Internet, Local intranet and Restricted sites. Internet,本地Intranet和受限站点均启用了保护模式。 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 无法在Selenium WebDriver中启动IE浏览器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Java + Selenium + Chromedriver 获胜。 服务器 2012 R2 - Java + Selenium + Chromedriver on win. Server 2012 R2 Windows Server 2012 R2启动时Red5 1.05失败 - Red5 1.05 on Windows Server 2012 R2 startup fails 在 Windows Server 2012 R2 上安装 Websense 软件时出错 - Error Installing Websense Software on Windows Server 2012 R2 如何在Windows Server 2012 R2上部署Spring Boot应用程序? - How can I deploy a spring-boot application on Windows Server 2012 R2? Tesseract 工作正常,除了在一台设备上给我 windows server 2012 r2 找不到指定的模块 - Tesseract work fine except on one device give me the Specified module not be found with windows server 2012 r2 在Windows 2012 R2上使用log4j启动Java jar - Start java jar with log4j on Windows 2012 R2 使用Selenium Webdriver的ExtJS测试自动化 - ExtJS Test Automation using Selenium Webdriver 使用Selenium WebAPI进行Jira测试自动化 - Jira Test Automation Using Selenium WebAPI 使用通用类对Java进行Selenium自动化测试 - using general class for Selenium automation test with java 尝试使用Selenium WebDriver测试Web应用程序时,弹出一个错误,提示无法连接到本地主机 - Trying to test a web application using selenium webdriver, a error that pops showing not abe to connect to the local host
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM