Jquery 如何知道哪个查询(*)项满足我的需要?
从查询结果看不到哪一个与文本框匹配。我的查询结果如下,但现在我需要找到文本框并在文本框中输入单词,然后单击搜索按钮(从HTML)。我可以看到文本框的id为“forminput”,但我不能使用perfoAction将文本设置为文本框。我如何点击按钮?我应该使用哪个标签 (有关html,请参见中的按视图源。) 我有以下问题:Jquery 如何知道哪个查询(*)项满足我的需要?,jquery,html,calabash,Jquery,Html,Calabash,从查询结果看不到哪一个与文本框匹配。我的查询结果如下,但现在我需要找到文本框并在文本框中输入单词,然后单击搜索按钮(从HTML)。我可以看到文本框的id为“forminput”,但我不能使用perfoAction将文本设置为文本框。我如何点击按钮?我应该使用哪个标签 (有关html,请参见中的按视图源。) 我有以下问题: 我想在文本框中输入文本,但我不知道哪个查询项是文本框 如何在框中输入文本 按钮是哪一项 如何单击按钮开始搜索 这是web的查询*结果: [ 0] {
[ 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}"
}
]
首先,如果您使用webView,您应该使用
查询“webView css:'*'”
而不是简单的查询“*”
来获取所有元素。
我想在文本框中输入文本,但我不知道哪个查询项是文本框 您将找到所有带有
query“webView css:'input'”的文本框
。然后在其中找到所需的文本框,例如,使用query“webView css:'input[name=\'q\']”“
如何在框中输入文本 使用
set\u text
方法,例如set\u text“webView css:'input[name=\'q\'”,“text”
按钮是哪一项 这取决于网页的实现。您应该查看
query“webView css:'*'”
的输出。通常,元素在该输出中的列出顺序与它们在网页上的显示顺序相同。因此,如果按钮位于输入字段之后,它将在query
输出中紧跟其后
如何单击按钮开始搜索 使用
touch
命令,例如touch“webView css:'input[class=\'btn\']”“
关于使用葫芦android文档中的WebView。如果输入字段中有提示文本,也可以使用简单的“点击‘提示文本’”命令来解决此问题 例如,如果您的用户名有提示文本“username”,那么您可以尝试“点击‘username’” 对于按钮,如果有文本,您可以使用相同的按钮。例如“登录”,然后点击“登录”
我知道它在iOS上有效,但我不确定它是否适用于HTML测试。谢谢你更新我的问题。但是有一个答案丢失了。谢谢你,Dmitry,我会尝试你的方法。然后我在名为“q”的输入字段中输入“test”,然后在id为“([^\“]*)”的输入字段中输入“([^\“]*)”$/do| text,css | set| text”webView css:“input”[name=“q\”],“text”end然后我按下类为“btn”的按钮,然后/^I按下id为“([^\”]*)”$/do | css | touch”的按钮webView css:“input[class=“btn”]”end