繁体   English   中英

硒测试在本地计算机上运行,​​但不通过詹金斯运行

[英]Selenium tests run on local machine but not through jenkins

在本地计算机上的Visual Studio中使用C#运行Selenium测试时,测试运行正常且全部通过。 但是,当我尝试在詹金斯上运行它们时,它们将失败。 如果我使用FireFox,那么Jenkins可以正常运行。 但是,问题在于我的老板想使用IE,因为这是我们公司最常用的。

这是无法运行的代码:

[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:对URL http:// localhost:61076 / session的远程WebDriver服务器的HTTP请求在60秒后超时。 ---> System.Net.WebException:操作已超时。

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

在System.Net.HttpWebRequest.GetResponse()在OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest请求)-内部异常堆栈跟踪的结尾-在OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest请求)在OpenQA处的OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(在Command处的OpenQA.Selenium.Remote.Remote。 OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor,ICapabilities requiredCapabilities)处于OpenQA.Selenium.IE.Internet.r.InternetExplorerDriver..ctor(String InternetExplorerDriverServerDirector.String.Selenium.Remote.Remote。 c:\\ Users \\ eedward7 \\ Desktop \\ Selenium \\ Selenium \\ UnitTest1.cs中的Tests.openBrowser():第50行

如果有人提出任何建议,那将是令人惊讶的,因为我现在在做什么方面无所适从。

使用以下选项尝试chromeDriver

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.AddArguments("test-type");
chromeOptions.AddArguments("no-sandbox");
new ChromeDriver(chromeOptions);

暂无
暂无

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

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