lefthandedgoat / canopy

f# web automation and testing library, built on top of Selenium (friendly to c# also)
http://lefthandedgoat.github.io/canopy/
MIT License
506 stars 115 forks source link

pinToMonitor is still mentioned in documentation even though it is no longer supported in code. #460

Open avargaslopez24 opened 5 years ago

avargaslopez24 commented 5 years ago

I don't know if this was an intentional reversion or not, but pinToMonitor is no longer defined in the source code. It does still show up on the website documentation however.

lefthandedgoat commented 5 years ago

Good find. Looking at the old code I think I can add it back, but if you tell it to pin to a monitor that does not exist it will move the browser off the screen and it will be lost.

It depended on a function to get monitor count that does not exist in .net core 2.

avargaslopez24 commented 5 years ago

Looking at the code, a workaround may be just make it a user defined value rather than a function call. Something along the lines of forcing users to set a canopy.screenmonitorCount value of non 1 before calling pintoMonitor?

Otherwise it's not a huge deal since I believe most users are running their UI tests headless making this a minor inconvenience.

lefthandedgoat commented 5 years ago

ah yes I could check that.

olivercoad commented 5 years ago

Any update on this? pinToMonitor is still in the documentation but not defined. Will .NET Core 3.0 support this?

lefthandedgoat commented 5 years ago

@olivercoad

let pinToMonitor n =
    let n' = if n < 1 then 1 else n
    if System.Windows.Forms.SystemInformation.MonitorCount >= n' then
        let workingArea = System.Windows.Forms.Screen.AllScreens.[n'-1].WorkingArea
        browser.Manage().Window.Position <- new System.Drawing.Point(workingArea.X, 0)
        browser.Manage().Window.Maximize()

That is the old code. I dont know if System.Windows.Forms.SystemInformation.MonitorCount is in .net Core 3.0 or System.Windows.Forms.Screen.AllScreens

For now I will remove from documentation