Reputation: 833
I enjoy using the wonderful webdriver package. But one thing that's a bit odd is that the Firefox browser type doesn't support commandline options. Can anyone help how I can run firefox headless mode with commandline options? I'm guessing I could use firefox profile but after much googling I couldn't find headless mode linked to firefox profile.
data Browser = Firefox { -- |The firefox profile to use. If Nothing,
-- a default temporary profile is automatically created
-- and used.
ffProfile :: Maybe (PreparedProfile Firefox)
-- |Firefox logging preference
, ffLogPref :: LogLevel
-- |Server-side path to Firefox binary. If Nothing,
-- use a sensible system-based default.
, ffBinary :: Maybe FilePath
-- |Available after Firefox 52, and required only for Firefox
-- geckodriver. Indicates whether untrusted and self-signed TLS
-- certificates are implicitly trusted on navigation for the
-- duration of the session.
, ffAcceptInsecureCerts :: Maybe Bool
}
| Chrome { -- |Version of the Chrome Webdriver server server to use
--
-- for more information on chromedriver see
-- <https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver>
chromeDriverVersion :: Maybe String
-- |Server-side path to Chrome binary. If Nothing,
-- use a sensible system-based default.
, chromeBinary :: Maybe FilePath
-- |A list of command-line options to pass to the
-- Chrome binary.
, chromeOptions :: [String]
-- |A list of extensions to use.
, chromeExtensions :: [ChromeExtension]
-- | Experimental options not yet exposed through a standard API.
, chromeExperimentalOptions :: Object
}
Upvotes: 3
Views: 435
Reputation: 362
For now, there's no specific switch built into the Haskell library, so you'll have to use the additionalCaps
field inside the wdCapabilities
field of your WDConfig
, rather than the browser
field, and include an args
array inside a moz:firefoxOptions
aeson object like this:
firefoxConfig ∷ WDConfig
firefoxConfig = defaultConfig {
wdCapabilities = defaultCaps {
additionalCaps = [
("moz:firefoxOptions", object [
("args", Array (fromList [String "--headless"]))
])
]
}
}
Anything else undocumented in Haskell that you wish to pass to Firefox will also go there.
This is explained in Mozilla's documentation.
Upvotes: 3