简体   繁体   English

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

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

When running Selenium tests with C# in Visual Studio on my local machine the tests run fine and all pass. 在本地计算机上的Visual Studio中使用C#运行Selenium测试时,测试运行正常且全部通过。 However when I try to run them on jenkins they fail. 但是,当我尝试在詹金斯上运行它们时,它们将失败。 If I use FireFox then Jenkins runs fine. 如果我使用FireFox,那么Jenkins可以正常运行。 The problem with that though is that my boss wants to use IE because that's what our company uses most. 但是,问题在于我的老板想使用IE,因为这是我们公司最常用的。

Here is the code that is failing to run: 这是无法运行的代码:

[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")));
}

Here is the Jenkins error message: 这是詹金斯(Jenkins)错误消息:

Initialization method Selenium.Tests.openBrowser threw exception. 初始化方法Selenium.Tests.openBrowser引发异常。 OpenQA.Selenium.WebDriverException: OpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://localhost:61076/session timed out after 60 seconds. OpenQA.Selenium.WebDriverException:OpenQA.Selenium.WebDriverException:对URL http:// localhost:61076 / session的远程WebDriver服务器的HTTP请求在60秒后超时。 ---> System.Net.WebException: The operation has timed out. ---> System.Net.WebException:操作已超时。

And Last but not least the Stacktrace: 最后但并非最不重要的Stacktrace:

at System.Net.HttpWebRequest.GetResponse() at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request) --- End of inner exception stack trace --- at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request) at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute) at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute) at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters) at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities) at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities) at OpenQA.Selenium.IE.InternetExplorerDriver..ctor(String internetExplorerDriverServerDirectory, InternetExplorerOptions options) at Selenium.Tests.openBrowser() in c:\\Users\\eedward7\\Desktop\\Selenium\\Selenium\\UnitTest1.cs:line 50 在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行

If anyone has any suggestions that would be amazing because I am at a loss right now on what to do. 如果有人提出任何建议,那将是令人惊讶的,因为我现在在做什么方面无所适从。

Try chromeDriver with these options 使用以下选项尝试chromeDriver

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

暂无
暂无

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

相关问题 无法通过Jenkins执行NUnit Selenium测试-目标计算机主动拒绝连接 - Unable to execute NUnit Selenium tests through Jenkins - target machine actively refused connection Jenkins使用C#上的Access DataBase Engine构建Selenium测试,获取Microsoft.ACE.OLEDB.12.0'提供程序未在本地计算机上注册 - Jenkins build with Access DataBase Engine on C# for Selenium Tests,Getting Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine 单元测试应该在本地计算机上运行吗? - Should Unit Tests Be Run On A Local Machine? 如何在作为 Windows 服务运行的 Jenkins 上以无头模式使用 Firefox 运行 Selenium 测试(C#、.NET) - How to run Selenium tests (C#, .NET) with Firefox in headless mode on Jenkins running as Windows service 如何通过Selenium读取一个Excel的数据文件,而C#的本机没有安装Interop和Microsoft Excel? - How to read an Excel data file through Selenium without Interop and Microsoft Excel installed in the Local machine in C#? 通过 Selenium 单元测试访问 Syncfusion 下拉菜单 - Accessing a Syncfusion Dropdown through Selenium Unit Tests 在同一台机器上运行Selenium驱动程序的多个实例 - Run multiple instances of Selenium driver in same machine 无法并行运行测试(Selenium grid + NUnit) - Cannot run tests in parallel (Selenium grid + NUnit) Github Actions run Nunit Selenium 测试问题 - Github Actions run Nunit Selenium tests question 在Selenium测试运行时捕获URL - Capturing URL while Selenium Tests run
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM