Calabash如何在cordova app中的下拉选择元素中选择一个值

时间:2015-10-26 13:25:51

标签: cordova cucumber automated-tests calabash

我的.rb步骤定义文件中有这个脚本

触摸(" webView css:'选择#MySelect'")

但是我无法查询选项元素,也找不到用calabash访问它的方法,有什么帮助吗?

当我查询select元素时,我得到以下内容

[
    [0] {
             "center" => {
            "X" => 384,
            "Y" => 321
        },
            "webView" => "<UIWebView: 0x7fcdd2421e90; frame = (0 0; 768 1024); autoresize = W+H; layer = <CALayer: 0x7fcdd2456790>>",
           "nodeName" => "SELECT",
                 "id" => "ACTION_TYPE",
        "textContent" => "\n        \n      To DoPhone CallMeetingReminderOther",
              "class" => "",
               "rect" => {
                   "x" => 384,
              "height" => 40,
                   "y" => 321,
               "width" => 734,
                "left" => 17,
                 "top" => 301,
            "center_y" => 321,
            "center_x" => 384
        },
           "nodeType" => "ELEMENT_NODE"
    }
]

3 个答案:

答案 0 :(得分:1)

正在渲染的元素可能没有type选项。使用查询(“webview css:'*'”)查找所有元素,并尝试使用简单的文本搜索在控制台中查找元素。

答案 1 :(得分:0)

在iOS上,您应该查看xpath和JavaScript API。

https://github.com/calabash/calabash-ios/wiki/06-WebView-Support

还有这个示例应用程序:

https://github.com/calabash/ios-webview-test-app

答案 2 :(得分:-1)

我找到了解决方案

js =“document.getElementsByTagName('option')[3] .selected ='selected'” 查询(“webView”,{calabashStringByEvaluatingJavaScript:js})