首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Selenium测试在本地机器上运行,但不通过jenkins运行。

Selenium测试在本地机器上运行,但不通过jenkins运行。
EN

Stack Overflow用户
提问于 2016-07-25 15:31:52
回答 1查看 812关注 0票数 0

在我的本地机器上用C#在Visual中运行Selenium测试时,测试运行良好,并且全部通过。然而,当我试图在jenkins上运行它们时,它们失败了。如果我使用FireFox,那么Jenkins运行得很好。但问题是,我的老板想要使用IE,因为这是我们公司最常用的。

下面是无法运行的代码:

代码语言:javascript
复制
[TestInitialize]
public void openBrowser()
{
    //Start Opening browser

    var options = new InternetExplorerOptions()
    {
        InitialBrowserUrl = baseURL,
        IntroduceInstabilityByIgnoringProtectedModeSettings = true,
        IgnoreZoomLevel = true,
        EnableNativeEvents = false
    };

    string IE_DRIVER_PATH = @"C:\Users\eedward7\Desktop\Selenium";

    driver = new InternetExplorerDriver(IE_DRIVER_PATH, options);    
    driver.Manage().Window.Maximize();
    driver.Navigate().GoToUrl(this.baseURL);

    WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(15));
    wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.Id("ctl00_ContentPlaceHolder1_Login1_UserName")));
    driver.FindElementById("ctl00_ContentPlaceHolder1_Login1_UserName").SendKeys(userID);
    driver.FindElementById("ctl00_ContentPlaceHolder1_Login1_Password").SendKeys(password);

    wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.Id("ctl00_ContentPlaceHolder1_Login1_LoginButton")));
    driver.FindElementById("ctl00_ContentPlaceHolder1_Login1_LoginButton").Click();
    wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.Id("ctl00_TreeView1t6")));
}

以下是Jenkins错误消息:

初始化方法Selenium.Tests.openBrowser抛出异常。OpenQA.Selenium.WebDriverException: OpenQA.Selenium.WebDriverException:对远程WebDriver服务器的http://localhost:61076/session请求在60秒后超时。-> System.Net.WebException:操作超时了。

最后但并非最不重要的是Stacktrace:

在OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest请求下的System.Net.HttpWebRequest.GetResponse()(字典‘2参数)在OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)在OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor ( ICapabilities desiredCapabilities)在OpenQA.Selenium.IE.InternetExplorerDriver..ctor(String internetExplorerDriverServerDirectory ( InternetExplorerOptions options)在Selenium.Tests.openBrowser()在c:\Users\eedward7\Desktop\Selenium\Selenium\UnitTest1.cs:line 50中

如果有人有任何建议的话,那就太棒了,因为我现在对该做什么感到不知所措。

EN

回答 1

Stack Overflow用户

发布于 2016-08-19 13:45:19

使用以下选项尝试chromeDriver

代码语言:javascript
复制
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.AddArguments("test-type");
chromeOptions.AddArguments("no-sandbox");
new ChromeDriver(chromeOptions);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38571885

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档