webdriver-0.3.1: a Haskell client for the Selenium WebDriver protocol

Safe HaskellNone

Test.WebDriver.Firefox.Profile

Contents

Description

A module for working with Firefox profiles. Firefox profiles are manipulated in pure code and then "prepared" for network transmission.

Synopsis

Profiles

data Firefox Source

Phantom type used in the parameters of Profile and PreparedProfile

data Profile b Source

This structure allows you to construct and manipulate profiles in pure code, deferring execution of IO operations until the profile is "prepared". This type is shared by both Firefox and Opera profile code; when a distinction must be made, the phantom type parameter is used to differentiate.

Constructors

Profile 

Fields

profileFiles :: [(FilePath, FilePath)]

A set of filepaths pointing to files to place in the extension directory. The first tuple element is the source path. The second tuple element is the destination path relative to the extension of the file.

profilePrefs :: HashMap Text ProfilePref

A map of Firefox preferences. These are the settings found in the profile's prefs.js, and entries found in about:config

Instances

Eq (Profile b) 
Show (Profile b) 

data PreparedProfile b Source

Represents a profile that has been prepared for network transmission. The profile cannot be modified in this form.

Preferences

data ProfilePref Source

A profile preference value. This is the subset of JSON values that excludes arrays, objects, and null.

class ToPref a whereSource

A typeclass to convert types to profile preference values

Methods

toPref :: a -> ProfilePrefSource

addPref :: ToPref a => Text -> a -> Profile b -> Profile bSource

Add a new preference entry to a profile, overwriting any existing entry with the same key.

getPref :: Text -> Profile b -> Maybe ProfilePrefSource

Retrieve a preference from a profile by key name.

deletePref :: Text -> Profile b -> Profile bSource

Delete an existing preference entry from a profile. This operation is silent if the preference wasn't found.

Extensions

addExtension :: FilePath -> Profile b -> Profile bSource

Add a new extension to the profile. The file path should refer to an .xpi file or an extension directory on the filesystem. If possible, you should avoiding adding the same extension twice to a given profile.

deleteExtension :: String -> Profile b -> Profile bSource

Delete an existing extension from the profile. The string parameter should refer to an .xpi file or directory located within the extensions directory of the profile. This operation has no effect if the extension was never added to the profile.

Loading and preparing profiles

prepareProfile :: MonadBaseControl IO m => Profile Firefox -> m (PreparedProfile Firefox)Source

Prepare a firefox profile for network transmission. Internally, this function constructs a Firefox profile within a temp directory, archives it as a zip file, and then base64 encodes the zipped data. The temporary directory is deleted afterwards.

NOTE: because this function has to copy the profile files into a a temp directory before zip archiving them, this operation is likely to be slow for large profiles. In such a case, consider using prepareLoadedProfile_ or prepareZippedProfile instead.

prepareTempProfile :: MonadBaseControl IO m => (Profile Firefox -> Profile Firefox) -> m (PreparedProfile Firefox)Source

Apply a function on a default profile, and prepare the result. The Profile passed to the handler function is the default profile used by sessions when Nothing is specified

Preparing profiles from disk

loadProfile :: MonadBaseControl IO m => FilePath -> m (Profile Firefox)Source

Load an existing profile from the file system. Any prepared changes made to the Profile will have no effect to the profile on disk.

prepareLoadedProfile :: MonadBaseControl IO m => FilePath -> (Profile Firefox -> Profile Firefox) -> m (PreparedProfile Firefox)Source

Convenience function to load an existing Firefox profile from disk, apply a handler function, and then prepare the result for network transmission.

NOTE: like prepareProfile, the same caveat about large profiles applies.

prepareLoadedProfile_ :: MonadBase IO m => FilePath -> m (PreparedProfile a)Source

Efficiently load an existing profile from disk and prepare it for network transmission.

Preparing zip archives

prepareZippedProfile :: MonadBase IO m => FilePath -> m (PreparedProfile a)Source

Prepare a zip file of a profile on disk for network transmission. This function is very efficient at loading large profiles from disk.

prepareZipArchive :: Archive -> PreparedProfile aSource

Prepare a zip archive of a profile for network transmission.

prepareRawZip :: ByteString -> PreparedProfile aSource

Prepare a ByteString of raw zip data for network transmission