Skip to content

Instantly share code, notes, and snippets.

@IvanRainbolt
Created August 24, 2020 02:26
Show Gist options
  • Save IvanRainbolt/42b8c0c7fe3742e741e40373582be86e to your computer and use it in GitHub Desktop.
Save IvanRainbolt/42b8c0c7fe3742e741e40373582be86e to your computer and use it in GitHub Desktop.
Attempt at screen shot using fsx/F# canopy
#if INTERACTIVE
#r @"C:\Users\netaz\.nuget\packages\canopy\2.1.5\lib\netstandard2.0\canopy.dll"
#r @"C:\Users\netaz\.nuget\packages\selenium.webdriver\3.141.0\lib\netstandard2.0\WebDriver.dll"
#r @"C:\Users\netaz\.nuget\packages\newtonsoft.json\12.0.3\lib\netstandard2.0\Newtonsoft.Json.dll"
#r @"D:\OneDrive\T\canopy.experiment\bin\Debug\netcoreapp3.1\runtimes\win\lib\netcoreapp3.0\System.Drawing.Common.dll"
#endif
open System
open canopy.classic
open canopy.runner.classic
#if INTERACTIVE
canopy.configuration.chromeDir <- @"C:\Users\netaz\.nuget\packages\selenium.webdriver.chromedriver\84.0.4147.3001\driver\win32"
#else
canopy.configuration.chromeDir <- System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)
#endif
printfn "READY_"
start chrome
url "https://localhost:44395/"
let all () =
"Check for home page load" &&& fun _ ->
"body > app > div.main > div.content.px-4 > h1" == "Hello, world!"
//alternative format
ntest "Check for home page load" (fun _ ->
"body > app > div.main > div.content.px-4 > h1" == "Hello, world!"
)
run
let counterlink = "body > app > div.sidebar > div:nth-child(2) > ul > li:nth-child(2) > a"
click counterlink
let path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\canopy\"
let path2 = @"D:\OneDrive\_ScreenShots\"
printfn "path: %s" path
let filename = DateTime.Now.ToString("MMM-d_HH-mm-ss-fff")// + ".png"
let filename2 = @"D:\OneDrive\_ScreenShots\" + DateTime.Now.ToString("MMM-d_HH-mm-ss-fff") //+ ".png"
//canopy.parallell.scree
screenshot path2 filename2
printfn "END_"
printfn "\nPress a key to end."
Console.ReadKey() |> ignore
quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment