【发布时间】:2016-07-20 18:26:41
【问题描述】:
试图远程执行 selenium 测试时卡住了。我们正在尝试在 TeamCity 服务器上执行 Selenium 测试。我知道这是个坏主意,但这不是我在这里的原因。 超级基本的 Nunit selenium webdriver / chrome。
[TestFixture]
public class Mytest1
{
private IWebDriver driver;
private StringBuilder verificationErrors;
private string baseURL;
private bool acceptNextAlert = true;
[SetUp]
public void SetupTest()
{
ChromeOptions options = new ChromeOptions();
options.AddArgument("\"no-sandbox\"");
driver = new ChromeDriver(options);
baseURL = "http://example.com/";
verificationErrors = new StringBuilder();
}
[TearDown]
public void TeardownTest()
{
try
{
driver.Quit();
}
catch (Exception)
{
// Ignore errors if unable to close the browser
}
Assert.AreEqual("", verificationErrors.ToString());
}
[Test]
public void TheMytest1Test()
{
driver.Navigate().GoToUrl(baseURL + "/somepage/");
driver.FindElement(By.LinkText("linktest")).Click();
driver.FindElement(By.CssSelector("div.container-div.caption")).Click();
}
当我从 VS 运行它时,我看到“正在启动 chromeDriver ver 2.22 等。只允许本地连接。”测试运行 100%。 我将更改提交到有 Nunit 任务运行器的 teamcity (v9.x)。反对测试。这就是它消亡的地方。直接在构建服务器上测试我在构建日志中看到以下内容。
[18:07:43][Step 3/5] Starting ChromeDriver 2.22.397933 (1cab651507b88dec79b2b2a22d1943c01833cc1b) on port 50513
[18:07:43][Step 3/5] Only local connections are allowed.
[18:08:46]
[SeleniumTests.Mytest1.TheMytest1Test] OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL http://localhost:50513/session timed out after 60 seconds.
----> System.Net.WebException : The operation has timed out
TearDown : System.NullReferenceException : Object reference not set to an instance of an object.
[18:08:46]
[SeleniumTests.Mytest1.TheMytest1Test] 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.Chrome.ChromeDriver..ctor(ChromeOptions options)
at SeleniumTests.Mytest1.SetupTest()
--WebException
at System.Net.HttpWebRequest.GetResponse()
at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
--TearDown
at SeleniumTests.Mytest1.TeardownTest()
我可以尝试使用 chrome.exe 做一些事情,但就是无法做到。这是不断弹出的错误。任何想法如何解决这个问题?我的假设是这是一个与权限相关的问题,但完全卡住了。
【问题讨论】:
标签: selenium teamcity selenium-chromedriver