Skip to content

Instantly share code, notes, and snippets.

@OnurGumus
Created December 17, 2019 11:21
Show Gist options
  • Save OnurGumus/01f4eb91d7383931fc290a102a9e4039 to your computer and use it in GitHub Desktop.
Save OnurGumus/01f4eb91d7383931fc290a102a9e4039 to your computer and use it in GitHub Desktop.
Canopy
#r "packages/Selenium.WebDriver/lib/netstandard2.0/WebDriver.dll"
#r "packages/canopy/lib/netstandard2.0/canopy.dll"
#r "packages/Newtonsoft.Json/lib/netstandard2.0/Newtonsoft.Json.dll"
//these are similar to C# using statements
open canopy.runner.classic
open canopy.classic
canopy.configuration.chromeDir <- @"."
//start an instance of chrome
start chrome
//this is how you define a test
"taking canopy for a spin" &&& fun _ ->
//this is an F# function body, it's whitespace enforced
//go to url
url "http://lefthandedgoat.github.io/canopy/testpages/"
//assert that the element with an id of 'welcome' has
//the text 'Welcome'
"#welcome" == "Welcome"
//assert that the element with an id of 'firstName' has the value 'John'
"#firstName" == "John"
//change the value of element with
//an id of 'firstName' to 'Something Else'
"#firstName" << "Something Else"
//verify another element's value, click a button,
//verify the element is updated
"#button_clicked" == "button not clicked"
click "#button"
"#button_clicked" == "button clicked"
//run all tests
run()
printfn "press [enter] to exit"
System.Console.ReadLine() |> ignore
quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment