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

Any instructions on how to setup a .fsx script file #457

Open rodsantest1 opened 5 years ago

rodsantest1 commented 5 years ago

How do I setup imports and references to use .fsx script file?

I'm using VS 2017 FX 4.6.1

See image

lefthandedgoat commented 5 years ago

This may help you:

https://github.com/lefthandedgoat/canopy/issues/148

amirrajan commented 5 years ago

And this: https://github.com/lefthandedgoat/canopy/issues/385

rodsantest1 commented 5 years ago

How does CanopyRepl work in canopy-lite? I tried fsi CanopyRepl.fsx but nothing happened. I was thinking it would somehow allow me to run a statement line by line like in old Visual Studio version where you can press Alt+Enter on a line to execute that line only.

halcwb commented 5 years ago

I setup a script file using the paket generate_load_scripts command. I can just load the generated fsx file in my script file like: #load "./../../../.paket/load/net472/UITests/uitests.group.fsx".

I can start up a browser, create a test and have the test run. However, the only problem is that if I repeat throwing the code to the REPL, the test will be activated twice (because it is again added). So, I would like to clear the list of tests to be run. I tried this:


#load "./../../../.paket/load/net472/UITests/uitests.group.fsx"

open System
open System.IO
open canopy
open canopy.runner.classic
open canopy.configuration
open canopy.classic
open canopy.types

let filepath = __SOURCE_DIRECTORY__
let driverpath =
    @"./../../../packages/uitests/Selenium.WebDriver.ChromeDriver/driver/win32"
let chromepath = Path.Combine(filepath, driverpath)

chromeDir <- chromepath
suites <- [ new suite() ]
start chrome
"check if the app is loaded" &&& fun _ ->
    // go to the url
    url "http://localhost:8080/"
    // check if the elmish-app div is displayed
    displayed "#elmish-app"
run()
quit()

But trying to start with a fresh set of tests by suites <- [ new suite() ] doesn't work.

lefthandedgoat commented 5 years ago

@halcwb What you have seems reasonable.

Are you running this twice? #load "./../../../.paket/load/net472/UITests/uitests.group.fsx"

Or running it one time, and then pasting the contents of the fsx the second time?

halcwb commented 5 years ago

I run the complete script once, then the lines including and following suites <- [ new suite() ]. This will run one test but will report the result from the previous tests. If I run the complete script, the result is the same, however. So, the previous tests are still cached bij the fsi.

P.s. Besides this, it works like a charm! Great!!!

halcwb commented 5 years ago

P.P.S. Beware of this problem. I.e. incorrect order of reference with first the canop reference and then the selenium webdriver reference instead of vica versa. You need to correct this manually in the group.fsx script generated by Paket.