From ccc8657d15c12ae492b70af6f97db937134434cc Mon Sep 17 00:00:00 2001 From: naveed Date: Tue, 9 Aug 2016 15:45:06 -0500 Subject: [PATCH 1/2] Added positionBrowser command --- docs/content/actions.fsx | 8 ++++++++ src/canopy/canopy.fs | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/docs/content/actions.fsx b/docs/content/actions.fsx index 3e87851c..356a4576 100644 --- a/docs/content/actions.fsx +++ b/docs/content/actions.fsx @@ -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 ---------- diff --git a/src/canopy/canopy.fs b/src/canopy/canopy.fs index b4b89395..eb01d5b7 100644 --- a/src/canopy/canopy.fs +++ b/src/canopy/canopy.fs @@ -862,6 +862,22 @@ 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 count = browsers.Length + let maxWidth = w / count + + 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()) From 829862af8d0a737ba06be22f6fabaa54b8130a09 Mon Sep 17 00:00:00 2001 From: naveed Date: Tue, 9 Aug 2016 15:57:41 -0500 Subject: [PATCH 2/2] removed unneeded code --- src/canopy/canopy.fs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/canopy/canopy.fs b/src/canopy/canopy.fs index eb01d5b7..787bc1da 100644 --- a/src/canopy/canopy.fs +++ b/src/canopy/canopy.fs @@ -866,8 +866,6 @@ let tile (browsers : IWebDriver list) = 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 count = browsers.Length - let maxWidth = w / count let x = left * w / 100 let y = top * h / 100