Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change a dropdown in an F# Canopy UI Testing Script

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?

like image 340
Graham Avatar asked Apr 11 '14 19:04

Graham


People also ask

How do I edit an existing drop-down list in Excel?

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.

How do I edit a drop-down list in Excel macro?

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.


1 Answers

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"
like image 94
lefthandedgoat Avatar answered Nov 02 '22 17:11

lefthandedgoat