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

早过忘川 提交于 2019-12-08 17:05:38

问题


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?


回答1:


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"


来源:https://stackoverflow.com/questions/23021251/how-to-change-a-dropdown-in-an-f-canopy-ui-testing-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!