| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Test.Sandwich.WebDriver.Windows
Description
Functions for manipulating browser windows.
Synopsis
- setWindowLeftSide :: (WebDriverMonad m context, MonadReader context m, WebDriver m) => m ()
- setWindowRightSide :: (WebDriverMonad m context, MonadReader context m, WebDriver m) => m ()
- setWindowFullScreen :: (WebDriverMonad m context, MonadReader context m, WebDriver m) => m ()
- getScreenResolution :: MonadIO m => WebDriver -> m (Int, Int, Int, Int)
- getResolution :: HasCallStack => IO (Int, Int, Int, Int)
- getResolutionForDisplay :: HasCallStack => Int -> IO (Int, Int, Int, Int)
Window positioning
setWindowLeftSide :: (WebDriverMonad m context, MonadReader context m, WebDriver m) => m () Source #
Position the window on the left 50% of the screen.
setWindowRightSide :: (WebDriverMonad m context, MonadReader context m, WebDriver m) => m () Source #
Position the window on the right 50% of the screen.
setWindowFullScreen :: (WebDriverMonad m context, MonadReader context m, WebDriver m) => m () Source #
Fullscreen the browser window.
Screen resolution
getScreenResolution :: MonadIO m => WebDriver -> m (Int, Int, Int, Int) Source #
Get the screen resolution as (x, y, width, height). (The x and y coordinates may be nonzero in multi-monitor setups.)
This function works with both normal RunMode and Xvfb mode.
Lower-level
Note: previously we got the screen resolution on Linux using the X11 Haskell library.
This was a troublesome dependency because it wouldn't build on Hackage, forcing us to upload the documentation manually.
It also caused problems when trying to make the demos easy to run on a clean machine or a Mac.
So instead, we now implement platform-specific getResolution functions.
On Linux, the simplest way seems to be to parse the output of xrandr. This is the approach taken by
at least one other library called screenres.
The other way to do it would be to load the x11 and/or xinerama libraries like is done in
screeninfo,
but again, that would require users to install those libraries. Just using xrandr itself seems like an easier
dependency.
getResolutionForDisplay Source #
Arguments
| :: HasCallStack | |
| => Int | Display number |
| -> IO (Int, Int, Int, Int) | Returns (x, y, width, height) |
Get the resolution for a specific display.