使用Calablash android在Dropbox登录webview中输入用户名和密码

时间:2016-06-14 12:50:25

标签: android calabash calabash-android

我正在创建一个预计会在dropbox中登录的测试。因此,应用程序启动了Dropbox登录webview。 使用query("webView css:'input'")我可以检索两个输入:登录名和密码。

当我尝试使用enter_text(query("webView css:'input'").first,"email@gmail.com")设置电子邮件字段时,出现错误:

RuntimeError: map {"class"=>"text-input-input autofocus", "nodeType"=>"ELEMENT_NODE", "id"=>"pyxl14", "calSavedIndex"=>5, "html"=>"<input class=\"text-input-input autofocus\" type=\"email\" name=\"login_email\" id=\"pyxl14\">", "textContent"=>"", "rect"=>{"y"=>640, "x"=>52, "center_x"=>540, "height"=>89, "width"=>976, "top"=>220, "left"=>20, "center_y"=>685}, "nodeName"=>"INPUT", "webView"=>"NoResourceEntry-6"}, query failed because: java.util.LinkedHashMap cannot be cast to java.lang.String

知道如何解决这个问题吗?谢谢!

2 个答案:

答案 0 :(得分:1)

我设法设置了文本,它有效,但我无法理解问题的命令有什么不同。 解决方案是:enter_text("webView css:'input[name=login_email]'", "email@gmail.com")

可能enter_textquery无法相处

答案 1 :(得分:0)

我建议您尝试使用xpath在enter_text函数的第一个参数中限制查询过滤器:

.wrap {
  width: 300px;
  background: #fff;
}
.narrow {
  display: flex;
  flex-wrap: wrap;
}
.narrow > * {
  background: #ccc;
  border: 2px solid #fff;
  padding: 10px;
  color: #fff;
}