检查Android应用的属性值时返回了异常值

时间:2019-03-02 15:36:22

标签: mobile automated-tests appium appium-android java-client

最近,我将我的appium版本更新为 1.11.1 ,并在进行了基本的验证(例如检查Android应用程序的新屏幕布局中的可点击元素状态)之后(之前我曾回顾过所有项目都是通过UI Automator Viewer工具“ clickable = false” ),因此在执行测试后,我在响应中看到所有项目都返回了带有属性“ clickable的项目= true” 代替,size()方法返回14个元素,而不是期望值'0'。

在此处执行验证步骤示例:

"driver.findElementsByAndroidUIAutomator("new UiSelector().clickable(true)").size()"

以及来自Appium服务器的日志响应:

[debug] [W3C (ee1567a8)] Calling AppiumDriver.findElements() with args: ["-android uiautomator","new UiSelector().clickable(true)","ee1567a8-d179-433a-870b-61403e6ce2f8"]
[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[debug] [BaseDriver] Waiting up to 10000 ms for condition
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"-android uiautomator","selector":"new UiSelector().clickable(true)","context":"","multiple":true}}
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"-android uiautomator","selector":"new UiSelector().clickable(true)","context":"","multiple":true}}
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'new UiSelector().clickable(true)' using 'ANDROID_UIAUTOMATOR' with the contextId: '' multiple: true
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Parsing selector: new UiSelector().clickable(true)
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] UiSelector coerce type: boolean arg: true
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[CLICKABLE=true]
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements selector:UiSelector[CLICKABLE=true]
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Element[] is null: (0)
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements tmp selector:UiSelector[INSTANCE=0, CLICKABLE=true]
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Element[] is null: (1)
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements tmp selector:UiSelector[INSTANCE=1, CLICKABLE=true]
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Element[] is null: (2)
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements tmp selector:UiSelector[INSTANCE=2, CLICKABLE=true]
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Element[] is null: (3)
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements tmp selector:UiSelector[INSTANCE=3, CLICKABLE=true]
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Element[] is null: (4)
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements tmp selector:UiSelector[INSTANCE=4, CLICKABLE=true]
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Element[] is null: (5)
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements tmp selector:UiSelector[INSTANCE=5, CLICKABLE=true]
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Element[] is null: (6)
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements tmp selector:UiSelector[INSTANCE=6, CLICKABLE=true]
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Element[] is null: (7)
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements tmp selector:UiSelector[INSTANCE=7, CLICKABLE=true]
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Element[] is null: (8)
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements tmp selector:UiSelector[INSTANCE=8, CLICKABLE=true]
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Element[] is null: (9)
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements tmp selector:UiSelector[INSTANCE=9, CLICKABLE=true]
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Element[] is null: (10)
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements tmp selector:UiSelector[INSTANCE=10, CLICKABLE=true]
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Element[] is null: (11)
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements tmp selector:UiSelector[INSTANCE=11, CLICKABLE=true]
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Element[] is null: (12)
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements tmp selector:UiSelector[INSTANCE=12, CLICKABLE=true]
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Element[] is null: (13)
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] getElements tmp selector:UiSelector[INSTANCE=13, CLICKABLE=true]
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":[{"ELEMENT":"2"},{"ELEMENT":"3"},{"ELEMENT":"4"},{"ELEMENT":"5"},{"ELEMENT":"6"},{"ELEMENT":"7"},{"ELEMENT":"8"},{"ELEMENT":"9"},{"ELEMENT":"10"},{"ELEMENT":"11"},{"ELEMENT":"12"},{"ELEMENT":"13"},{"ELEMENT":"14"}]}
[debug] [W3C (ee1567a8)] Responding to client with driver.findElements() result: [{"element-6066-11e4-a52e-4f735466cecf":"2","ELEMENT":"2"},{"element-6066-11e4-a52e-4f735466cecf":"3","ELEMENT":"3"},{"element-6066-11e4-a52e-4f735466cecf":"4","ELEMENT":"4"},{"element-6066-11e4-a52e-4f735466cecf":"5","ELEMENT":"5"},{"element-6066-11e4-a52e-4f735466cecf":"6","ELEMENT":"6"},{"element-6066-11e4-a52e-4f735466cecf":"7","ELEMENT":"7"},{"element-6066-11e4-a52e-4f735466cecf":"8","ELEMENT":"8"},{"element-6066-11e4-a52e-4f735466cecf":"9","ELEMENT":"9"},{"element-6066-11e4-a52e-4f735466cecf":"10","ELEMENT":"10"},{"element-6066-11e4-a52e-4f735466cecf":"11","ELEMENT":"11"},{"element-6066-11e4-a52e-4f735466cecf":"12","ELEMENT":"12"},{"element-6066-11e4-a52e-4f735466cecf":"13","ELEMENT":"13"},{"element-6066-11e4-a52e-4f735466cecf":"14","ELEMENT":"14"}]
[HTTP] <-- POST /wd/hub/session/ee1567a8-d179-433a-870b-61403e6ce2f8/elements 200 5188 ms - 775

如果有人认为这可能与Appium最新版本本身有关,或者我在验证步骤中遗漏了其他任何东西,那么有人可以提供帮助吗?

  

尽管没有发现有关最新Appium版本HERE

的任何问题,

注释:在使用的不同库及其版本下方。

  • Java客户端版本:7.0.0
  • Selenium Java客户端:3.141.59
  • Appium版本:1.11.1

1 个答案:

答案 0 :(得分:0)

由于Appium将 UIAutomator2 用于其自己的客户端-服务器实现,因此使用旧版本的UI Automator Viewer工具(使用Android SDK中的本机UIAutomator)无关紧要强>。

正确的检查器是Appium Desktop,通常会在发布新的Appium服务器后立即提供其新版本。它不仅对UX友好,而且在下面使用Appium,并保证您在其中找到的内容可以在测试中使用。