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?
Edit a drop-down list with items that have been entered manually. On the worksheet where you applied the drop-down list, select a cell that has the drop-down list. Go to Data > Data Validation. On the Settings tab, click in the Source box, and then change your list items as needed.
Select a cell or cells that reference your Excel Data Validation list, i.e. cells containing a drop-down box that you want to edit. Click Data Validation (Excel ribbon > Data tab). Delete or type new items in the Source box. Click OK to save the changes and close the Excel Data Validation window.
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With