lefthandedgoat / canopy

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

How works scripting with parallel testing? #430

Closed kikkoi closed 5 years ago

kikkoi commented 6 years ago

I am interested to canopy 2.0. Can use surely the with parallel testing F# Interactive? Can give simple example of parallel testing with F# Interactive?

lefthandedgoat commented 6 years ago

I do not have any examples using the parallel testing in interactive.

You should be able to, but only if you are able to run unit tests in parallel in interactive. canopy 1.x used a global mutable instance of a browser which inhibited having multiple browsers and tests going at the same time. Two new apis are introduced in 2.0 which fix this. Running tests in parallel has not been added to the runner, you will need to use a test runner like Expecto or nUnit for that.

kikkoi commented 6 years ago

I appreciate your reply.

I did tried instanced version in F# Interactive and got this trouble with

sandbox2.fsx(15,1): error FS0074: The type referenced through 'OpenQA.Selenium.ISearchContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'WebDriver'.

My script:

#I @"C:\Users\kikko\.dotnet\x64\sdk\NuGetFallbackFolder\netstandard.library\2.0.1\build\netstandard2.0\ref\"
#I @"C:\Users\kikko\.nuget\packages\selenium.webdriver\3.11.0\lib\netstandard2.0\"
#I @"C:\Users\kikko\.nuget\packages\canopy\2.0.0\lib\"
#r "netstandard.dll"
#r "WebDriver.dll"
#r "canopy.dll"

open canopy.parallell.instanced

canopy.configuration.chromeDir <- "C:\chrome"
canopy.screen.screenWidth <- 1600
canopy.screen.screenHeight <- 768

let x = new Instance()
x.start canopy.types.Chrome

x.url "http://localhost:5000/"

Everything has already been referenced. Did I miss something or it's a bug?

lefthandedgoat commented 6 years ago

I will look into this tonight. I never use interactive with testing, so I am very rusty.

haf commented 6 years ago

@kikkoi You can use https://github.com/haf/canopy/blob/parallel/tests/ParallelUsage/Explore.fsx as an example, if you want an fsx example that works. I haven't released a separate nuget with these changes yet though.