dotnetcore

Selenium PageFactory deprecated for .NET Core

See alternate implementation here.

accessing configuration in test projects

Accessing configuration and using dependency injection in Test Projects

building from source

References are in /eng, check building from source.

endpoint configuration

Specify URLs using ASPNETCORE_URLS environment variable or --urls command-line argument.

installing dotnet core

Powershell

# install dotnet core sdk
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -useb 'https://dot.net/v1/dotnet-install.ps1' -OutFile dotnet-install.ps1
.\dotnet-install.ps1 -Channel LTS -InstallDir 'C:\Program Files\dotnet'

To do the same but from a nightly (master) use --Channel master.

.\dotnet-install.ps1 -Channel master -InstallDir 'C:\Program Files\dotnet'

Installing the runtime only

.\dotnet-install.ps1 -Version 3.0.0-preview9-19410-12 -Runtime dotnet -InstallDir 'C:\Program Files\dotnet'

More info on dotnet-install.ps1.

Bash

curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel LTS # install the latest LTS
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --version 6.0.418 # install a specific version

Update PATH:

export PATH=$PATH:$HOME/.dotnet

May also need DOTNET_ROOT=$HOME/.dotnet:

blocking urls in selenium

Sometimes we want to block specific URLs from loading, for example Google Analytics so we don’t artificially inflate our statistics.

readonly string[] _blockUrls = new [] {
    "www.google-analytics.com"
};

public ChromeDriver GetDriver() 
{
    var options = new ChromeOptions();
    var rules = string.Join(',', _blockUrls.Select(r => $"MAP {r} 127.0.0.1"));
    options.AddArgument($"--host-resolver-rules={rules}");
    return new ChromeDriver(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), options);
}

commits

My contributions to .NET Core 3.0

selenium packages for dotnet core

Selenium.WebDriver Selenium.WebDriver.ChromeDriver Selenium.Chrome.WebDriver - for moving chromedriver.exe into bin DotNetSeleniumExtras.WaitHelpers - for ExpectedConditions

installing dotnet core sdk on linux

package manager

manual

curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel LTS --install-dir /usr/local/bin/