Skip to content

Instantly share code, notes, and snippets.

@allanx2000
Last active January 23, 2020 02:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save allanx2000/eefd7177e8d9c05ba8b610e80ad7fb68 to your computer and use it in GitHub Desktop.
Save allanx2000/eefd7177e8d9c05ba8b610e80ad7fb68 to your computer and use it in GitHub Desktop.
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
private ChromeDriver driver;
protected ChromeDriver Driver {
get
{
if (driver == null)
{
//E:\DEV\chrome-win\chrome.exe
string bin = Workspace.Instance.ChromeBinary;
var fi = new FileInfo(bin);
var service = ChromeDriverService.CreateDefaultService(fi.DirectoryName);
service.HideCommandPromptWindow = true;
var options = new ChromeOptions()
{
AcceptInsecureCertificates = true,
UnhandledPromptBehavior = UnhandledPromptBehavior.Ignore,
};
if (!string.IsNullOrEmpty(bin))
{
options.BinaryLocation = bin;
}
options.AddArgument("headless");
driver = new ChromeDriver(service, options);
}
return driver;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment