Running Selenium Tests in Chrome (Headless mode) on a VSTS Hosted Agent

smd

Is it possible to run Selenium C# tests on a hosted agent within a Visual Studio Team Services build/release using the Chrome driver in headless mode?

I've seen contradictory information indicating this is and isn't possible currently. This user voice idea seems to suggest Chrome is pre-installed on the hosted agents:

https://visualstudio.uservoice.com/forums/330519-visual-studio-team-services/suggestions/19387174-install-headless-chrome-on-hosted-build-servers

Current Setup

As part of the setup of my tests (in code), I'm indicating that I want the Chrome driver to run in headless mode and they do so when run within a local instance of VS.

Example:

var options = new ChromeOptions();
options.AddArgument("headless");
options.AddArgument("disable-gpu");

var driver = new ChromeDriver(options);

When the tests are run as part of the release definition within VSTS, the following error is thrown:

2018-02-20T13:21:10.7954002Z Error Message:
2018-02-20T13:21:10.7954156Z  unknown error: cannot find Chrome binary
2018-02-20T13:21:10.7954340Z   (Driver info: chromedriver=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73),platform=Windows NT 10.0.14393 x86_64)
2018-02-20T13:21:10.7954487Z Stack Trace:
2018-02-20T13:21:10.7954620Z System.InvalidOperationException: unknown error: cannot find Chrome binary
2018-02-20T13:21:10.7955947Z   (Driver info: chromedriver=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73),platform=Windows NT 10.0.14393 x86_64)
2018-02-20T13:21:10.7956136Z    at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
2018-02-20T13:21:10.7956387Z    at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
2018-02-20T13:21:10.7956557Z    at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
2018-02-20T13:21:10.7956729Z    at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
2018-02-20T13:21:10.7956927Z    at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout)
2018-02-20T13:21:10.7957106Z    at OpenQA.Selenium.Chrome.ChromeDriver..ctor(String chromeDriverDirectory, ChromeOptions options)

I've ensured the chromedriver.exe has been copied over to the bin directory and is included in the build artifacts that are being used by the release process.

Alternatives

I know you can setup a private agent to run these tests on, but I wanted to avoid doing this if possible and make use of the hosted agents within VSTS.

I've also managed to successfully run the tests using the PhantomJS driver within VSTS, but again we want to be able to test exclusively against the Chrome browser if possible.

UPDATE

As per the accepted answer below (by Bernard Vander Beken), I managed to resolve this by inserting an additional release task to install Chrome silenty and unattended via a PowerShell script. This task (obviously) needs to be excuted prior to the test run so that the browser can then be used in headless mode within the Selenium tests.

Release Definition Example

Bernard Vander Beken

It should be possible, see https://github.com/Microsoft/vsts-agent/issues/1378

The hosted agent is running as Admin, so you should be able to install chrome as part of your build as long as chrome has unattended installation mode.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Running NPM on a self-hosted VSO Agent

分類Dev

Not able to play DRM content in Chrome headless mode

分類Dev

Headless Chrome Element is not clickable (works in browser mode)

分類Dev

VSTS Microsoft-Hosted Agent:仮想マシンのサイズ

分類Dev

VSTS Hosted Agent 2017 と PhantomJS が機能しない

分類Dev

TestNG Based Selenium Tests not running in Parallel

分類Dev

Selenium Grid - Webdriver - Whitescreens when running tests

分類Dev

How to run selenium tests in Chrome browser?

分類Dev

selenium.common.exceptions.InvalidSessionIdException using GeckoDriver Selenium Firefox in headless mode through Python

分類Dev

Start headless chrome in incognito

分類Dev

SyntaxError: Unexpected token when running selenium-javascript tests

分類Dev

VSTS Hosted Agent、ディスクに十分なスペースがありません

分類Dev

Hosted 2017AgentでAzureRMPowershellをアップグレードする(VSTS-Visual Studio Team Services)

分類Dev

Cannot register a build agent in VSTS

分類Dev

Confluent Platform KSQL in headless mode

分類Dev

Azure DevOps Hosted Build Agent MSI

分類Dev

SSIS Project Fails To Build On Self Hosted Agent

分類Dev

Azure PipelinesBizTalk-Microsoft Hosted Build Agent

分類Dev

"Inconclusive: Test not run" error running unit tests in debug mode in Visual Studio / Resharper

分類Dev

Relaxing Chrome's CSP while running tests (webdriver) (Content-Security-policy)

分類Dev

Running headless server on Windows via SSH

分類Dev

Selenium Firefox headless returns different results

分類Dev

OpenQA.Selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally while executing tests through Selenium start on linux

分類Dev

Selenium screenshots in VSTS (Azure DevOps)

分類Dev

Not able to run my CodeceptJS testcases in headless chrome

分類Dev

Rspec、Capybara、selenium_chrome_headless。リモートフォームを送信した後、応答を待つ

分類Dev

Chromeドライバーに--headlessを追加すると、Seleniumが機能しなくなります

分類Dev

Running AsyncHttpClient with JUNIT Tests

分類Dev

Connect containerized self-hosted agent with Azure DevOps

Related 関連記事

  1. 1

    Running NPM on a self-hosted VSO Agent

  2. 2

    Not able to play DRM content in Chrome headless mode

  3. 3

    Headless Chrome Element is not clickable (works in browser mode)

  4. 4

    VSTS Microsoft-Hosted Agent:仮想マシンのサイズ

  5. 5

    VSTS Hosted Agent 2017 と PhantomJS が機能しない

  6. 6

    TestNG Based Selenium Tests not running in Parallel

  7. 7

    Selenium Grid - Webdriver - Whitescreens when running tests

  8. 8

    How to run selenium tests in Chrome browser?

  9. 9

    selenium.common.exceptions.InvalidSessionIdException using GeckoDriver Selenium Firefox in headless mode through Python

  10. 10

    Start headless chrome in incognito

  11. 11

    SyntaxError: Unexpected token when running selenium-javascript tests

  12. 12

    VSTS Hosted Agent、ディスクに十分なスペースがありません

  13. 13

    Hosted 2017AgentでAzureRMPowershellをアップグレードする(VSTS-Visual Studio Team Services)

  14. 14

    Cannot register a build agent in VSTS

  15. 15

    Confluent Platform KSQL in headless mode

  16. 16

    Azure DevOps Hosted Build Agent MSI

  17. 17

    SSIS Project Fails To Build On Self Hosted Agent

  18. 18

    Azure PipelinesBizTalk-Microsoft Hosted Build Agent

  19. 19

    "Inconclusive: Test not run" error running unit tests in debug mode in Visual Studio / Resharper

  20. 20

    Relaxing Chrome's CSP while running tests (webdriver) (Content-Security-policy)

  21. 21

    Running headless server on Windows via SSH

  22. 22

    Selenium Firefox headless returns different results

  23. 23

    OpenQA.Selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally while executing tests through Selenium start on linux

  24. 24

    Selenium screenshots in VSTS (Azure DevOps)

  25. 25

    Not able to run my CodeceptJS testcases in headless chrome

  26. 26

    Rspec、Capybara、selenium_chrome_headless。リモートフォームを送信した後、応答を待つ

  27. 27

    Chromeドライバーに--headlessを追加すると、Seleniumが機能しなくなります

  28. 28

    Running AsyncHttpClient with JUNIT Tests

  29. 29

    Connect containerized self-hosted agent with Azure DevOps

ホットタグ

アーカイブ