macacajs / NoSmoke

A cross platform UI crawler which scans view trees then generate and execute UI test cases.
https://macacajs.github.io/NoSmoke
MIT License
198 stars 57 forks source link

searchValue无法根据resource-id值找到元素?默认都是text属性找元素吗? #43

Closed Archer456 closed 6 years ago

Archer456 commented 6 years ago

一 searchValue无法根据resource-id值找到元素?默认都是text属性找元素吗?

用这份androidTest.yml 也就是searchValue都是取的text属性的话 可以跑通。

`# 1. Initialization option

desiredCapabilities:

platformName: 'android'

udid: 45806625

app: '/home/cmd/app/acp4.7p.apk'

packages: 'com.sinacp.ggaicai'

activity: 'com.aicai.pluginhost.activity.MainActivity'

isWaitActivity: true

reuse: 3

testingPeriod: 36000

permissionPatterns: '[\"继续安装\",\"下一步\",\"好\",\"允许\",\"确定\",\"我知道\"]'

2. Crawling option

crawlingConfig:

platform: 'android'

targetElements:

INmy:

  actionType: 1

  searchValue : '我的'

loginUI:  

  actionType: 1

  searchValue : '立即登录/注册'        

loginAccount:

  actionType: 2

  searchValue : "手机号/用户名"

  actionValue : 'mdc123123'

loginPassword:

  actionType: 2

  searchValue : "登录密码"

  actionValue : '123123'

loginButton:

  actionType: 1

  searchValue : "登录"

clickTypes:

- 'android.widget.ImageView'

- 'android.widget.TextView'

- 'android.widget.Button'

- 'android.widget.LinearLayout'

editTypes:

- 'android.widget.EditText'

tabBarTypes:

- 'android.widget.TabWidget'`

但是全部换成或部分换成id属性的话却无法找到 不执行。

这份都两个 是用的text属性 可以找到并点击 但是后边的 searchValue : "com.sinacp.ggaicai:id/etUserName" 却无法找到并输入用户名。 `

1. Initialization option

desiredCapabilities: platformName: 'android' udid: 45806625 app: '/home/cmd/app/acp4.7p.apk' packages: 'com.sinacp.ggaicai' activity: 'com.aicai.pluginhost.activity.MainActivity' isWaitActivity: true reuse: 3 testingPeriod: 36000 permissionPatterns: '[\"继续安装\",\"下一步\",\"好\",\"允许\",\"确定\",\"我知道\"]'

2. Crawling option

crawlingConfig: platform: 'android' targetElements: INmy: actionType: 1 searchValue : '我的' loginUI:
actionType: 1 searchValue : '立即登录/注册'
loginAccount: actionType: 2 searchValue : "com.sinacp.ggaicai:id/etUserName" actionValue : 'mdc123' loginPassword: actionType: 2 searchValue : "com.sinacp.ggaicai:id/etPwd" actionValue : '123123' loginButton: actionType: 1 searchValue : "com.sinacp.ggaicai:id/tvLogin" clickTypes:

`

二 testingPeriod: 36000 这个是测试执行时间 我这样应该是设置的 106060 也就是10分钟 但从上述两个androidTest.yml 效果来看,是执行完该节 targetElements: 后优先的后 就直接停止了。

附上第二个androidTest.yml 的执行日志 , 可以看到执行到 立即登录/注册 后 根据id值 com.sinacp.ggaicai:id/etUserName 就没有执行后续,然后找到了个 com.sinacp.ggaicai:id/ivBack 返回主页后 就自行结束 遍历了

`cmd@TR:~/scripts/NoSmoke/android$ nosmoke -c androidTest.yml --verbose

server.js:15:12 [master] pid:1863 server start with config: { port: 5678, verbose: true, config: 'androidTest.yml', ip: '192.168.66.113', host: 'TR', loaded_time: '2018-01-11 14:38:22' } udid: undefined (node:1863) DeprecationWarning: 'root' is deprecated, use 'global' <-- GET / reporter generated: /home/cmd/scripts/NoSmoke/android/reports/2018-1-11-14-38-21-report.html --> GET / 200 initialize crawler {"index":"1","text":"我的","class":"android.widget.TextView","package":"com.sinacp.ggaicai","checkable":"false","checked":"false","clickable":"false","enabled":"true","focusable":"false","focused":"false","scrollable":"false","long-clickable":"false","password":"false","selected":"false","bounds":"[864,1971][1080,1980]","pathInParent":1,"xpath":"//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[5]/android.widget.TextView[1]","type":"android.widget.TextView"} {"index":"1","text":"立即登录/注册","resource-id":"com.acp.main:id/tvAccount","class":"android.widget.TextView","package":"com.sinacp.ggaicai","checkable":"false","checked":"false","clickable":"false","enabled":"true","focusable":"false","focused":"false","scrollable":"false","long-clickable":"false","password":"false","selected":"false","bounds":"[237,303][558,370]","pathInParent":1,"xpath":"//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.support.v4.view.ViewPager[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.RelativeLayout[1]/android.widget.LinearLayout[1]/android.widget.TextView[1]","type":"android.widget.TextView"} reporter generated: /home/cmd/scripts/NoSmoke/android/reports/2018-1-11-14-38-21-report.html <-- GET /2018-1-11-14-38-21/db2dfbb6-2954-4553-a287-ddbc7edb1ea8.png --> GET /2018-1-11-14-38-21/db2dfbb6-2954-4553-a287-ddbc7edb1ea8.png 200 <-- GET /2018-1-11-14-38-21/80583105-af13-4ac3-a6d1-69ac232cc007.png --> GET /2018-1-11-14-38-21/80583105-af13-4ac3-a6d1-69ac232cc007.png 200 <-- GET /2018-1-11-14-38-21/1c1cbfe7-428f-4b69-bbba-f606d16cfb91.png --> GET /2018-1-11-14-38-21/1c1cbfe7-428f-4b69-bbba-f606d16cfb91.png 200 {"NAF":"true","index":"0","resource-id":"com.sinacp.ggaicai:id/ivBack","class":"android.widget.ImageView","package":"com.sinacp.ggaicai","checkable":"false","checked":"false","clickable":"true","enabled":"true","focusable":"false","focused":"false","scrollable":"false","long-clickable":"false","password":"false","selected":"false","bounds":"[0,116][116,232]","type":"android.widget.ImageView","pathInParent":1,"xpath":"//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.RelativeLayout[1]/android.widget.ImageView[1]"} {"index":"1","text":"我的","class":"android.widget.TextView","package":"com.sinacp.ggaicai","checkable":"false","checked":"false","clickable":"false","enabled":"true","focusable":"false","focused":"false","scrollable":"false","long-clickable":"false","password":"false","selected":"false","bounds":"[864,1971][1080,1980]","pathInParent":1,"xpath":"//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[5]/android.widget.TextView[1]","type":"android.widget.TextView"} -----> Crawling Finished: <----- terminate due to timeout reporter generated: /home/cmd/scripts/NoSmoke/android/reports/2018-1-11-14-38-21-report.html `

SamuelZhaoY commented 6 years ago

https://github.com/macacajs/NoSmoke/issues/54 关于是否支持resource-id 的讨论,见这里