Я пытаюсь настроить Jenkins (версия 2.117) и запустить автоматические тесты, используя Selenium для стека .NET в Windows 10, а Jenkins работает как служба Windows.
Я пытаюсь использовать веб-драйвер Firefox с Firefox 56, который поддерживает режим без монитора.
Машина и программное обеспечение
- Windows 10 pro
- Дженкинс 2.117
- Selenium Webdriver (последняя версия на этот вопрос)
- Firefox 56, 32 бита
- GeckoDriver v0.16.1
- Visual Studio 2017 Enterprise
Селеновый тест
[TestClass]
public class SeleniumTest
{
[TestMethod]
[TestProperty("Selenium", "Google")]
public void GoToGoogle()
{
var options = new FirefoxOptions();
options.AddArgument("-headless");
var driver = new FirefoxDriver(options);
driver.Navigate().GoToUrl("https://www.google.com");
StringAssert.Contains(driver.PageSource, "Google");
}
}
Я могу заставить тест работать через Visual Studio, но не удается во время сборки на Jenkins.
Команда, использованная для запуска теста:
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\TestPlatform\vstest.console.exe" C:\Jenkins\workspace\WorkSpaceName\Tests\bin\ContinuousIntegration\Tests.dll /tests:Google /logger:trx
Jenkins Build Output
Вот сокращенный вывод журнала для сборки:
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\TestPlatform\vstest.console.exe" C:\Jenkins\workspace\WorkSpaceName\Tests\bin\ContinuousIntegration\Tests.dll /tests:Google /logger:trx
Microsoft (R) Test Execution Command Line Tool Version 15.6.1
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test discovery, please wait...
1525798591265 geckodriver INFO Listening on 127.0.0.1:58807
1525798592565 geckodriver::marionette INFO Starting browser \\?\C:\Program Files (x86)\Mozilla Firefox\firefox.exe with args ["-marionette", "-headless"]
*** You are running in headless mode.
1525798592835 addons.xpi WARN Error parsing extensions state: [Exception... "Component returned failure code: 0x80520012 (NS_ERROR_FILE_NOT_FOUND) [amIAddonManagerStartup.readStartupData]" nsresult: "0x80520012 (NS_ERROR_FILE_NOT_FOUND)" location: "JS frame :: resource://gre/modules/addons/XPIProvider.jsm :: loadExtensionState :: line 1554" data: no] Stack trace: loadExtensionState()@resource://gre/modules/addons/XPIProvider.jsm:1554 < getInstallState()@resource://gre/modules/addons/XPIProvider.jsm:1589 < checkForChanges()@resource://gre/modules/addons/XPIProvider.jsm:3109 < startup()@resource://gre/modules/addons/XPIProvider.jsm:2188 < callProvider()@resource://gre/modules/AddonManager.jsm:269 < _startProvider()@resource://gre/modules/AddonManager.jsm:739 < startup()@resource://gre/modules/AddonManager.jsm:906 < startup()@resource://gre/modules/AddonManager.jsm:3090 < observe()@jar:file:///C:/Program%20Files%20(x86)/Mozilla%20Firefox/omni.ja!/components/addonManager.js:65
1525798593164 Marionette INFO Enabled via --marionette
###!!! [Parent][MessageChannel] Error: (msgtype=0x240058,name=PContent::Msg_SetPluginList) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24004C,name=PContent::Msg_GMPsChanged) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x150084,name=PBrowser::Msg_UpdateNativeWindowHandle) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x150078,name=PBrowser::Msg_Destroy) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24001F,name=PContent::Msg_PreferenceUpdate) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24001F,name=PContent::Msg_PreferenceUpdate) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24001F,name=PContent::Msg_PreferenceUpdate) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24001F,name=PContent::Msg_PreferenceUpdate) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24001F,name=PContent::Msg_PreferenceUpdate) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24001F,name=PContent::Msg_PreferenceUpdate) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24001F,name=PContent::Msg_PreferenceUpdate) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24001F,name=PContent::Msg_PreferenceUpdate) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24001F,name=PContent::Msg_PreferenceUpdate) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24001F,name=PContent::Msg_PreferenceUpdate) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24001F,name=PContent::Msg_PreferenceUpdate) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24001F,name=PContent::Msg_PreferenceUpdate) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24001F,name=PContent::Msg_PreferenceUpdate) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24001F,name=PContent::Msg_PreferenceUpdate) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24001F,name=PContent::Msg_PreferenceUpdate) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24001F,name=PContent::Msg_PreferenceUpdate) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24001F,name=PContent::Msg_PreferenceUpdate) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24001F,name=PContent::Msg_PreferenceUpdate) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24001F,name=PContent::Msg_PreferenceUpdate) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24001F,name=PContent::Msg_PreferenceUpdate) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24001F,name=PContent::Msg_PreferenceUpdate) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24001F,name=PContent::Msg_PreferenceUpdate) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24001F,name=PContent::Msg_PreferenceUpdate) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24001F,name=PContent::Msg_PreferenceUpdate) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24003F,name=PContent::Msg_LoadProcessScript) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24003F,name=PContent::Msg_LoadProcessScript) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x2400FC,name=PContent::Msg_AsyncMessage) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24001F,name=PContent::Msg_PreferenceUpdate) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24001F,name=PContent::Msg_PreferenceUpdate) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24001F,name=PContent::Msg_PreferenceUpdate) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24001F,name=PContent::Msg_PreferenceUpdate) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24001F,name=PContent::Msg_PreferenceUpdate) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x2400FC,name=PContent::Msg_AsyncMessage) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24001F,name=PContent::Msg_PreferenceUpdate) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x24001F,name=PContent::Msg_PreferenceUpdate) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x150084,name=PBrowser::Msg_UpdateNativeWindowHandle) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x150078,name=PBrowser::Msg_Destroy) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x150084,name=PBrowser::Msg_UpdateNativeWindowHandle) Channel error: cannot send/recv
###!!! [Parent][MessageChannel] Error: (msgtype=0x150078,name=PBrowser::Msg_Destroy) Channel error: cannot send/recv
1525798595876 addons.productaddons WARN Failed downloading via XHR, status: 0, reason: error
Failed GoToGoogle
Error Message:
Test method SeleniumTest.GoToGoogle threw exception:
OpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://localhost:58807/session timed out after 60 seconds. ---> System.Net.WebException: The request was aborted: The operation has timed out.
Stack Trace:
at System.Net.HttpWebRequest.GetResponse()
at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
--- End of inner exception stack trace ---
at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
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.Firefox.FirefoxDriver..ctor(FirefoxOptions options)
at StateOfMichigan.DisabilityServices.BusinessResources.Tests.UnitTests.SeleniumTest.GoToGoogle() in C:\Jenkins\workspace\MiBRS-22944-02\Tests\UnitTests\SeleniumTest.cs:line 16
Total tests: 1. Passed: 0. Failed: 1. Skipped: 0.
Test Run Failed.
Test execution time: 1.0295 Minutes
При просмотре URL-адреса, который он упоминает в выходных данных журнала (http://localhost:58807/session), я получаю следующий ответ:
{
"value": {
"error": "unknown command",
"message": "GET /session did not match a known command",
"stacktrace": "stack backtrace:\n 0: 0x489f6f - <no info>\n 1: 0x48ad59 - <no info>\n 2: 0x43a15d - <no info>\n 3: 0x42ec0f - <no info>\n 4: 0x423c30 - <no info>\n 5: 0x4078fa - <no info>\n 6: 0x6bc939 - <no info>\n 7: 0x415d0d - <no info>\n 8: 0x6b6e43 - <no info>\n 9: 0x7fff56fe8364 - BaseThreadInitThunk"
}
}
Теперь ответ выше может быть связан с тем, что браузер отправляет запрос GET
вместо POST
.
Jenkins Service Properties
Я пробовал несколько итераций конфигов для службы Jenkins:
Конфигурация по умолчанию
- Использование учетной записи "Local System"
- Нет взаимодействия с рабочим столом
Результат: То же, что и выше
Настроенная локальная системная учетная запись
- Использование учетной записи "Local System"
- Установите флажок Разрешить службе взаимодействовать с рабочим столом
Результат: То же, что и выше
Использование локального пользователя "Jenkins"
Результат: исключение: ему не удалось найти активный каталог BEAN на этапе инициализации
Использование моего пользователя Active Directory
- Мой собственный пользователь и пароль
- У меня есть права администратора на компьютере
Результат: То же, что и исходная задача выше
Как запустить тесты Selenium в автономном режиме Firefox при запуске Jenkins в качестве службы Windows?
Обновление 1: Похоже, что может быть проблема с моей версией Firefox (v56) или GeckoDriver (v0.16.1). Переключение на Chrome 66 и ChromeDriver 2.38.552522 работает нормально.