MicrosoftWebDriver fails when constructing while running under TeamCity agent's windows service

拟墨画扇 提交于 2019-12-22 09:15:28

问题


Using: * Windows 10 Pro * MicrosoftWebDriver Release 14393

I'm having troubles with running my UI tests suite with Edge (while Chrome, Firefox and IE11 - all work). The problem does not occur while running in standard, windows - development environment. The problem only occurs when trying to run these UI tests on CI (TeamCity) agent. The agent is configured to run as a Windows Service.

Firstly, when account running the agent service was given Administrator's account, I was being received the:

"Microsoft Web Driver can't be used with the Built-In Administrator account or while User Account Control is turned off."

error and browser didn't even bother to start. After some time of googling for the answer, I gave up with nothing. So I removed the Administrator's priviledges and the message was gone, but the driver kept failing at the construction phase:

Fatal Error [10:57:37][Step 1/1] OpenQA.Selenium.WebDriverException: Unexpected error. Unknown error [10:57:37][Step 1/1] w OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse) [10:57:37][Step 1/1] w OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters) [10:57:37][Step 1/1] w OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities) [10:57:37][Step 1/1] w OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities) [10:57:37][Step 1/1] w OpenQA.Selenium.Edge.EdgeDriver..ctor(EdgeDriverService service, EdgeOptions options) [10:57:37][Step 1/1] w Learn.UITests.Common.Infrastructure.Selenium.Setup.DriverFactory.CreateDriver(UITestsContext context) w DriverFactory.cs:wiersz 60 [10:57:37][Step 1/1] w Learn.UITests.Common.Infrastructure.Selenium.ContextBase.OnAssemblyStart() w my_code 24

The way I instantiate edge driver is just the default:

var ie11Driver = new InternetExplorerDriver(InternetExplorerDriverService.CreateDefaultService(driverPath));

Can someone point me what can I do to see my edge UI tests running under background windows service (same as IE11, Chrome and Firefox)?


回答1:


"Microsoft Web Driver can't be used with the Built-In Administrator account or while User Account Control is turned off."

This resolved it for me on Windows 10 Pro N. For full instructions on all Windows versions, check out this link

  1. Press and Hold the Windows key and Press R
  2. In the run dialog box, Type secpol.msc and Press Enter (Opens Local Security Policy)
  3. On the left pane, Navigate to Security Settings > Local Policies >Security Options
  4. Locate User Account Control Admin Approval Mode for the Built-in Administrator account on the right pane. Double Click it to open its properties
  5. Select Enabled in the Local Security Setting tab and Click Ok
  6. Now Restart your computer and check if it works now




回答2:


The way I solved this issue was create a new user on my windows 10 machine by running the lusrmgr.msc in windows search field. And then use this new user to run the jenkins service (Right click on the jenkins_slave service in the services window and click properties)




回答3:


Press and Hold the Windows key and Press R In the run dialog box, Type secpol.msc and Press Enter (Opens Local Security Policy) On the left pane, Navigate to Security Settings > Local Policies >Security Options and enable all options as given in image.

it solved my issue on win 10 vm



来源:https://stackoverflow.com/questions/41461217/microsoftwebdriver-fails-when-constructing-while-running-under-teamcity-agents

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!