From e693076ee17f3da6e4490d8938f0d48bad8c91d2 Mon Sep 17 00:00:00 2001 From: thomasjm Date: Fri, 9 Aug 2024 05:03:56 -0700 Subject: [PATCH] Be able to pass your own firefox profile in capabilities --- .../WebDriver/Internal/Capabilities/Extra.hs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/sandwich-webdriver/src/Test/Sandwich/WebDriver/Internal/Capabilities/Extra.hs b/sandwich-webdriver/src/Test/Sandwich/WebDriver/Internal/Capabilities/Extra.hs index 086c6234..0fbe4266 100644 --- a/sandwich-webdriver/src/Test/Sandwich/WebDriver/Internal/Capabilities/Extra.hs +++ b/sandwich-webdriver/src/Test/Sandwich/WebDriver/Internal/Capabilities/Extra.hs @@ -27,7 +27,6 @@ import Test.Sandwich.WebDriver.Internal.Binaries.Chrome.Types (ChromeVersion(..) import Test.Sandwich.WebDriver.Internal.Types import qualified Test.WebDriver as W import qualified Test.WebDriver.Firefox.Profile as FF -import UnliftIO.Exception #if MIN_VERSION_aeson(2,0,0) @@ -97,16 +96,14 @@ configureDownloadCapabilities :: ( MonadIO m ) => [Char] -> W.Capabilities -> m W.Capabilities configureDownloadCapabilities downloadDir caps@(W.Capabilities {W.browser=browser@(W.Firefox {..})}) = do - case ffProfile of - Nothing -> return () - Just _ -> liftIO $ throwIO $ userError [i|Can't support Firefox profile yet.|] - - profile <- liftIO $ FF.defaultProfile - & FF.addPref "browser.download.folderList" (2 :: Int) - & FF.addPref "browser.download.manager.showWhenStarting" False - & FF.addPref "browser.download.dir" downloadDir - & FF.addPref "browser.helperApps.neverAsk.saveToDisk" ("*" :: String) - & FF.prepareProfile + profile <- case ffProfile of + Just x -> pure x + Nothing -> liftIO $ FF.defaultProfile + & FF.addPref "browser.download.folderList" (2 :: Int) + & FF.addPref "browser.download.manager.showWhenStarting" False + & FF.addPref "browser.download.dir" downloadDir + & FF.addPref "browser.helperApps.neverAsk.saveToDisk" ("*" :: String) + & FF.prepareProfile return (caps { W.browser = browser { W.ffProfile = Just profile } }) configureDownloadCapabilities downloadDir caps@(W.Capabilities {W.browser=browser@(W.Chrome {..})}) = return $ caps { W.browser=browser' }