从查询结果中看不出哪个与文本框匹配。我的查询结果如下,但现在我需要在文本框中找到文本框并输入单词,然后单击HTML中的搜索按钮。我可以看到文本框的id是“forminput”,但我不能使用perfomAction将文本设置到文本框。我点击按钮怎么样?我应该使用哪个标签?
(对于html,请参见this web
中的查看来源我有以下问题:
这是网络的查询*结果:
[ 0] {
"id" => nil,
"enabled" => true,
"contentDescription" => nil,
"class" => "com.android.internal.policy.impl.PhoneWindow$DecorView",
"rect" => {
"center_y" => 142.0,
"center_x" => 120.0,
"height" => 284,
"y" => 0,
"width" => 240,
"x" => 0
},
"description" => "com.android.internal.policy.impl.PhoneWindow$DecorView{b2da1390 V.E..... R.....I. 0,0-240,284}"
},
[ 1] {
"id" => "action_bar_overlay_layout",
"enabled" => true,
"contentDescription" => nil,
"class" => "com.android.internal.widget.ActionBarOverlayLayout",
"rect" => {
"center_y" => 142.0,
"center_x" => 120.0,
"height" => 284,
"y" => 0,
"width" => 240,
"x" => 0
},
"description" => "com.android.internal.widget.ActionBarOverlayLayout{b2dfed00 V.ED.... ......I. 0,0-240,284 #1020313 android:id/action_bar_overlay_layout}"
},
[ 2] {
"id" => "content",
"enabled" => true,
"contentDescription" => nil,
"class" => "android.widget.FrameLayout",
"rect" => {
"center_y" => 169.5,
"center_x" => 120.0,
"height" => 229,
"y" => 55,
"width" => 240,
"x" => 0
},
"description" => "android.widget.FrameLayout{b2da5930 V.E..... ......I. 0,55-240,284 #1020002 android:id/content}"
},
[ 3] {
"id" => "container",
"enabled" => true,
"contentDescription" => nil,
"class" => "android.widget.FrameLayout",
"rect" => {
"center_y" => 169.5,
"center_x" => 120.0,
"height" => 229,
"y" => 55,
"width" => 240,
"x" => 0
},
"description" => "android.widget.FrameLayout{b2df76d0 V.E..... ......I. 0,0-240,229 #7f05003c app:id/container}"
},
[ 4] {
"id" => nil,
"enabled" => true,
"contentDescription" => nil,
"class" => "android.support.v4.app.NoSaveStateFrameLayout",
"rect" => {
"center_y" => 169.5,
"center_x" => 120.0,
"height" => 229,
"y" => 55,
"width" => 240,
"x" => 0
},
"description" => "android.support.v4.app.NoSaveStateFrameLayout{b2e2c3b8 V.E..... ......I. 0,0-240,229}"
},
[ 5] {
"id" => nil,
"enabled" => true,
"contentDescription" => nil,
"class" => "android.widget.LinearLayout",
"rect" => {
"center_y" => 169.5,
"center_x" => 120.0,
"height" => 229,
"y" => 55,
"width" => 240,
"x" => 0
},
"description" => "android.widget.LinearLayout{b2df86d8 V.E..... ......I. 0,0-240,229}"
},
[ 6] {
"id" => "mywebview",
"enabled" => true,
"contentDescription" => "Web View",
"class" => "android.webkit.WebView",
"rect" => {
"center_y" => 169.5,
"center_x" => 120.0,
"height" => 229,
"y" => 55,
"width" => 240,
"x" => 0
},
"description" => "android.webkit.WebView{b2dbdd18 VFEDHVC. .F....I. 0,0-240,229 #7f05003d app:id/mywebview}"
},
[ 7] {
"id" => "action_bar_container",
"enabled" => true,
"contentDescription" => nil,
"class" => "com.android.internal.widget.ActionBarContainer",
"rect" => {
"center_y" => 37.0,
"center_x" => 120.0,
"height" => 36,
"y" => 19,
"width" => 240,
"x" => 0
},
"description" => "com.android.internal.widget.ActionBarContainer{b2dab088 V.ED.... ......I. 0,19-240,55 #1020314 android:id/action_bar_container}"
},
[ 8] {
"id" => "action_bar",
"enabled" => true,
"contentDescription" => nil,
"class" => "com.android.internal.widget.ActionBarView",
"rect" => {
"center_y" => 37.0,
"center_x" => 120.0,
"height" => 36,
"y" => 19,
"width" => 240,
"x" => 0
},
"description" => "com.android.internal.widget.ActionBarView{b2d98560 V.E..... ......I. 0,0-240,36 #1020315 android:id/action_bar}"
},
[ 9] {
"id" => nil,
"enabled" => false,
"contentDescription" => nil,
"class" => "android.widget.LinearLayout",
"rect" => {
"center_y" => 37.0,
"center_x" => 66.5,
"height" => 36,
"y" => 19,
"width" => 119,
"x" => 7
},
"description" => "android.widget.LinearLayout{b2dab638 V.....C. ......I. 7,0-126,36}"
},
[10] {
"id" => nil,
"enabled" => true,
"contentDescription" => nil,
"class" => "com.android.internal.widget.ActionBarView$HomeView",
"rect" => {
"center_y" => 37.0,
"center_x" => 22.0,
"height" => 36,
"y" => 19,
"width" => 30,
"x" => 7
},
"description" => "com.android.internal.widget.ActionBarView$HomeView{b2de3f00 V.E..... ......I. 0,0-30,36}"
},
[11] {
"id" => "home",
"enabled" => true,
"contentDescription" => nil,
"class" => "android.widget.ImageView",
"rect" => {
"center_y" => 37.0,
"center_x" => 22.0,
"height" => 24,
"y" => 25,
"width" => 24,
"x" => 10
},
"description" => "android.widget.ImageView{b2e14210 V.ED.... ......I. 3,6-27,30 #102002c android:id/home}"
},
[12] {
"id" => nil,
"enabled" => true,
"contentDescription" => nil,
"class" => "android.widget.LinearLayout",
"rect" => {
"center_y" => 36.5,
"center_x" => 81.5,
"height" => 19,
"y" => 27,
"width" => 89,
"x" => 37
},
"description" => "android.widget.LinearLayout{b2dda508 V.E..... ......I. 30,8-119,27}"
},
[13] {
"id" => "action_bar_title",
"enabled" => true,
"contentDescription" => nil,
"class" => "android.widget.TextView",
"text" => "TestWebView",
"rect" => {
"center_y" => 36.5,
"center_x" => 78.5,
"height" => 19,
"y" => 27,
"width" => 83,
"x" => 37
},
"description" => "android.widget.TextView{b2dbc4b8 V.ED.... ......I. 0,0-83,19 #1020265 android:id/action_bar_title}"
},
[14] {
"id" => nil,
"enabled" => true,
"contentDescription" => nil,
"class" => "com.android.internal.view.menu.ActionMenuView",
"rect" => {
"center_y" => 37.0,
"center_x" => 219.0,
"height" => 36,
"y" => 19,
"width" => 42,
"x" => 198
},
"description" => "com.android.internal.view.menu.ActionMenuView{b2df5188 V.ED.... ......I. 198,0-240,36}"
},
[15] {
"id" => nil,
"enabled" => true,
"contentDescription" => "More options",
"class" => "com.android.internal.view.menu.ActionMenuPresenter$OverflowMenuButton",
"rect" => {
"center_y" => 37.0,
"center_x" => 219.0,
"height" => 36,
"y" => 19,
"width" => 42,
"x" => 198
},
"description" => "com.android.internal.view.menu.ActionMenuPresenter$OverflowMenuButton{b2de1788 VFED..C. ......I. 0,0-42,36}"
}
]
提前谢谢
答案 0 :(得分:1)
首先,如果您正在使用WebView,则应使用query "webView css:'*'"
代替简单query "*"
来获取所有元素。
我想在文本框中输入文字,但我不知道哪个查询项是文本框。
您将找到query "webView css:'input'"
的所有文本框。然后在其中找到所需的一个,例如与query "webView css:'input[name=\"q\"]'"
。
如何在框中输入文字?
使用set_text
方法,例如set_text "webView css:'input[name=\"q\"]'", "text"
。
按钮是哪个项目?
这取决于网页的实施。您应该查看query "webView css:'*'"
的输出输出。通常,元素在输出中的列出顺序与网页上显示的顺序相同。因此,如果按钮位于输入字段之后,它将在query
输出中继续显示。
如何点击按钮开始搜索?
使用touch
命令,例如touch "webView css:'input[class=\"btn\"]'"
。
Here is a short info使用calabash-android文档中的WebViews。
答案 1 :(得分:1)
如果输入字段中有提示文字,您也可以使用简单的"点击提示文字'"来解决此问题。命令。
例如,如果您的用户名具有提示文字"用户名"。然后你可以尝试点击用户名'"。
对于按钮,如果有文本,则可以使用相同的按钮。例如"登录"然后点击“登录”"。
我知道它适用于iOS,但我不确定它是否适用于HTML测试。