Reputation: 3231
I am really enjoying using Canopy Web Testing to test out my .NET Web Apps with F#. However the documentation is sparse. I'm looking for a hint on how to change an HTML select
tag to select an element based on a value
of an option.
Right now, all I can manage to do is calling the click
event from Canopy, and then firing press down
the correct number of times in my test to get to the proper element. Of course, this means my tests all break if the number of elements in the dropdown changes.
Does anyone have an idea of how to use the option
tag's value to select it in the UI?
Upvotes: 10
Views: 1309
Reputation: 498
open canopy
open runner
start firefox
"taking canopy for a spin" &&& fun _ ->
url "http://lefthandedgoat.github.io/canopy/testpages/"
"#item_list" << read "option[value='2']"
"#item_list" == "Item 2"
run()
You could write your own helper method to improve this by doing
let option value = read <| sprintf "option[value='%s']" value
"taking canopy for a spin" &&& fun _ ->
url "http://lefthandedgoat.github.io/canopy/testpages/"
"#item_list" << option "2"
"#item_list" == "Item 2"
I will open an issue and add a feature so that you can do the below instead
"#item_list" << "2"
Upvotes: 16