From 2f31f907b510ad327bf9c98ca9c0039690d8cb1c Mon Sep 17 00:00:00 2001 From: Chris Holt Date: Fri, 15 Jul 2016 13:08:48 -0500 Subject: [PATCH] Improve support for chromium, fixes #276 --- src/canopy/canopy.fs | 12 +++++++++--- src/canopy/configuration.fs | 8 ++++++++ src/canopy/reporters.fs | 2 +- src/canopy/types.fs | 1 + 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/canopy/canopy.fs b/src/canopy/canopy.fs index eb97276b..79ef37da 100644 --- a/src/canopy/canopy.fs +++ b/src/canopy/canopy.fs @@ -30,6 +30,8 @@ let edgeBETA = EdgeBETA (* documented/actions *) let chrome = Chrome (* TODO/documented/actions *) +let chromium = Chromium +(* TODO/documented/actions *) let phantomJS = PhantomJS (* TODO/documented/actions *) let safari = Safari @@ -794,12 +796,16 @@ let start b = | IEWithOptionsAndTimeSpan(options, timeSpan) -> new IE.InternetExplorerDriver(ieDir, options, timeSpan) :> IWebDriver | EdgeBETA -> new Edge.EdgeDriver(edgeDir) :> IWebDriver | Chrome -> - let options = OpenQA.Selenium.Chrome.ChromeOptions() - options.AddArgument("test-type") //https://code.google.com/p/chromedriver/issues/detail?id=799 - new Chrome.ChromeDriver(chromeDir, options) :> IWebDriver + let options = OpenQA.Selenium.Chrome.ChromeOptions() + options.AddArgument("test-type") //https://code.google.com/p/chromedriver/issues/detail?id=799 + new Chrome.ChromeDriver(chromeDir, options) :> IWebDriver | ChromeWithOptions options -> new Chrome.ChromeDriver(chromeDir, options) :> IWebDriver | ChromeWithUserAgent userAgent -> chromeWithUserAgent userAgent | ChromeWithOptionsAndTimeSpan(options, timeSpan) -> new Chrome.ChromeDriver(chromeDir, options, timeSpan) :> IWebDriver + | Chromium -> + let options = OpenQA.Selenium.Chrome.ChromeOptions() + options.AddArgument("test-type") //https://code.google.com/p/chromedriver/issues/detail?id=799 + new Chrome.ChromeDriver(chromiumDir, options) :> IWebDriver | Firefox -> new FirefoxDriver() :> IWebDriver | FirefoxWithProfile profile -> new FirefoxDriver(profile) :> IWebDriver | FirefoxWithPath path -> new FirefoxDriver(new Firefox.FirefoxBinary(path), Firefox.FirefoxProfile()) :> IWebDriver diff --git a/src/canopy/configuration.fs b/src/canopy/configuration.fs index 753c04fc..b30d770f 100644 --- a/src/canopy/configuration.fs +++ b/src/canopy/configuration.fs @@ -10,6 +10,12 @@ let folderByOSType = | PlatformID.Unix -> @"/usr/bin/" | _ -> @"c:\" +let folderByOSTypeChromium = + match System.Environment.OSVersion.Platform with + | PlatformID.MacOSX + | PlatformID.Unix -> @"/usr/lib/chromium-browser" + | _ -> @"c:\" + //runner related (* documented/configuration *) let failFast = ref false @@ -20,6 +26,8 @@ let mutable failScreenshotFileName = fun (test : types.Test) (suite: types.suite (* documented/configuration *) let mutable chromeDir = folderByOSType +(* TODO/documented/configuration *) +let mutable chromiumDir = folderByOSTypeChromium (* documented/configuration *) let mutable ieDir = folderByOSType (* documented/configuration *) diff --git a/src/canopy/reporters.fs b/src/canopy/reporters.fs index 2458febb..11aef92f 100644 --- a/src/canopy/reporters.fs +++ b/src/canopy/reporters.fs @@ -189,7 +189,7 @@ type LiveHtmlReporter(browser : BrowserStartMode, driverPath : string, ?pinBrows | IEWithOptions options ->new OpenQA.Selenium.IE.InternetExplorerDriver(driverPath, options) :> IWebDriver | IEWithOptionsAndTimeSpan(options, timeSpan) -> new OpenQA.Selenium.IE.InternetExplorerDriver(driverPath, options, timeSpan) :> IWebDriver | EdgeBETA -> new OpenQA.Selenium.Edge.EdgeDriver(driverPath) :> IWebDriver - | Chrome -> + | Chrome | Chromium -> let options = OpenQA.Selenium.Chrome.ChromeOptions() options.AddArgument("test-type") //https://code.google.com/p/chromedriver/issues/detail?id=799 new OpenQA.Selenium.Chrome.ChromeDriver(driverPath, options) :> IWebDriver diff --git a/src/canopy/types.fs b/src/canopy/types.fs index 84e389f3..4ddf0efa 100644 --- a/src/canopy/types.fs +++ b/src/canopy/types.fs @@ -53,6 +53,7 @@ type BrowserStartMode = | ChromeWithOptions of Chrome.ChromeOptions | ChromeWithOptionsAndTimeSpan of Chrome.ChromeOptions * TimeSpan | ChromeWithUserAgent of string + | Chromium | Safari | PhantomJS | PhantomJSProxyNone