Skip to content

Commit

Permalink
Merge pull request #285 from navmed/master
Browse files Browse the repository at this point in the history
added action: positionBrowser
  • Loading branch information
lefthandedgoat authored Aug 13, 2016
2 parents 1786226 + 829862a commit 4ed2b0e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/content/actions.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,14 @@ let browser3 = browser

tile [browser1; browser2; browser3]

(**
positionBrowser
----
Position current browser on the screen - position is in percentages: positionBrowser left top width height
*)
positionBrowser 66 0 33 50


(**
currentUrl
----------
Expand Down
14 changes: 14 additions & 0 deletions src/canopy/canopy.fs
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,20 @@ let tile (browsers : IWebDriver list) =

setSize browsers 0

(* documented/actions *)
let positionBrowser left top width height =
let h = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height
let w = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width

let x = left * w / 100
let y = top * h / 100
let bw = width * w /100
let bh = height * h / 100

browser.Manage().Window.Size <- new System.Drawing.Size(bw, bh)
browser.Manage().Window.Position <- new System.Drawing.Point(x, y)

let private innerSize() =
let jsBrowser = browser :?> IJavaScriptExecutor
let innerWidth = System.Int32.Parse(jsBrowser.ExecuteScript("return window.innerWidth").ToString())
Expand Down

0 comments on commit 4ed2b0e

Please sign in to comment.