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
199 stars 58 forks source link

UnhandledPromiseRejectionWarning #38

Closed Archer456 closed 6 years ago

Archer456 commented 6 years ago

cmd@TR:~$ macaca doctor macaca-doctor version: 2.0.4

Node.js checklist: node env: /opt/nodejs/bin/node node version: v6.10.3

Android checklist: JAVA version is 1.8.0_151 JAVA_HOME is set to /usr/lib/jvm/java-8-oracle ANDROID_HOME is set to /opt/android-sdk-linux Platforms is set to /opt/android-sdk-linux/platforms/android-26 ADB tool is set to /opt/android-sdk-linux/platform-tools/adb gradle is installed, version: 3.5

Installed driver list: android: 2.0.45 chrome: 1.0.7 electron: 1.1.19

cmd@TR:~$ nosmoke -v 1.0.1

cmd@TR:~$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 16.04.3 LTS Release: 16.04 Codename: xenial

H5Test.yml内容

1. Initialization option

desiredCapabilities:

Web Configuration

platformName: 'Desktop' browserName: 'Electron' url: 'http://m.aicai.com/m/register.do?agentId=14759&vt=5'

2. Crawling option

Web Configuration

crawlingConfig: platform: 'pc-web' targetElements: CommonRegist: searchValue : '常规注册' loginAccount: searchValue : 'jq_account' actionValue : 'postsay123' loginPassword: searchValue : 'jq_comm_pass' actionValue : '$%^&*213' CellPhoneNumber: searchValue : 'jq_mobile' actionValue : '13751077575' loginButton: searchValue : 'common_registe' alertConfirm: searchValue : '该手机号已在本站注册过了,请更换手机号再试,多谢合作!' clickTypes:

macaca server Log cmd@TR:~$ macaca server --verbose

request.js:24:12 [master] pid:24658 get remote update info failed. index.js:18:12 [master] pid:24668 webdriver server start with config: { port: 3456, verbose: true, always: true, ip: '192.168.66.113', host: 'TR', loaded_time: '2018-01-04 15:15:16' } middlewares.js:17:10 [master] pid:24668 base middlewares attached router.js:133:10 [master] pid:24668 router set webdriver sdk launched responseHandler.js:11:12 [master] pid:24668 Recieve HTTP Request from Client[2018-01-04 15:15:43]: method: POST url: /wd/hub/session, jsonBody: {"desiredCapabilities":{"platformName":"Desktop","browserName":"Electron","url":"http://m.aicai.com/m/register.do?agentId=14759&vt=5"}} session.js:47:10 [master] pid:24668 Creating session, sessionId: 2b92cb8f-9bd5-4e2b-bc5e-f65c2a8f6de2. responseHandler.js:49:14 [master] pid:24668 Send HTTP Respone to Client[2018-01-04 15:15:46]: {"sessionId":"2b92cb8f-9bd5-4e2b-bc5e-f65c2a8f6de2","status":0,"value":"{\"platformName\":\"Desktop\",\"browserName\":\"Electron\",\"url\":\"http://m.aicai.com/m/register.do?agentId=14759&vt=5\"}"} responseHandler.js:11:12 [master] pid:24668 Recieve HTTP Request from Client[2018-01-04 15:15:46]: method: POST url: /wd/hub/session/2b92cb8f-9bd5-4e2b-bc5e-f65c2a8f6de2/url, jsonBody: {"url":"http://m.aicai.com/m/register.do?agentId=14759&vt=5"} responseHandler.js:49:14 [master] pid:24668 Send HTTP Respone to Client[2018-01-04 15:15:47]: {"sessionId":"2b92cb8f-9bd5-4e2b-bc5e-f65c2a8f6de2","status":0,"value":null} responseHandler.js:11:12 [master] pid:24668 Recieve HTTP Request from Client[2018-01-04 15:15:53]: method: GET url: /wd/hub/session/2b92cb8f-9bd5-4e2b-bc5e-f65c2a8f6de2/source, jsonBody: {} responseHandler.js:49:14 [master] pid:24668 Send HTTP Respone to Client[2018-01-04 15:15:53]: {"sessionId":"2b92cb8f-9bd5-4e2b-bc5e-f65c2a8f6de2","status":0,"value":"\"<link href=\\"https://rm.aicai.com/wap5/js/??plugins/lhgdialog/skins/chrome.css\\" rel=\\"stylesheet\\" id=\\"lhgdialoglink\\">\n \t\t\n\n\n\n\t\t\n\t\t<meta charset=\\"utf-8\\">\n\t\t<meta http-equiv=\\"Content-Type\\" content=\\"application/xhtml+xml; charset=utf-8\\">\n\t\t<meta http-equiv=\\"Cache-Control\\" content=\\"no-cache\\">\n\t\t<meta http-equiv=\\"Pragma\\" content=..."} responseHandler.js:11:12 [master] pid:24668 Recieve HTTP Request from Client[2018-01-04 15:15:53]: method: GET url: /wd/hub/session/2b92cb8f-9bd5-4e2b-bc5e-f65c2a8f6de2/url, jsonBody: {} responseHandler.js:49:14 [master] pid:24668 Send HTTP Respone to Client[2018-01-04 15:15:53]: {"sessionId":"2b92cb8f-9bd5-4e2b-bc5e-f65c2a8f6de2","status":0,"value":"\"http://m.aicai.com/m/register.do?agentId=14759&vt=5\""}

nosmoke Log cmd@TR:~/scripts/NoSmoke/web$ nosmoke -c H5Test.yml --verbose

server.js:15:12 [master] pid:24803 server start with config: { port: 5678, verbose: true, config: 'H5Test.yml', ip: '192.168.66.113', host: 'TR', loaded_time: '2018-01-04 15:15:43' } udid: undefined (node:24803) DeprecationWarning: 'root' is deprecated, use 'global' <-- GET / reporter generated: /home/cmd/scripts/NoSmoke/web/reports/2018-0-4-15:15:42-report.html --> GET / 200 initialize crawler reporter generated: /home/cmd/scripts/NoSmoke/web/reports/2018-0-4-15:15:42-report.html (node:24803) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'then' of undefined reporter generated: /home/cmd/scripts/NoSmoke/web/reports/2018-0-4-15:15:42-report.html reporter generated: /home/cmd/scripts/NoSmoke/web/reports/2018-0-4-15:15:42-report.html reporter generated: /home/cmd/scripts/NoSmoke/web/reports/2018-0-4-15:15:42-report.html reporter generated: /home/cmd/scripts/NoSmoke/web/reports/2018-0-4-15:15:42-report.html reporter generated: /home/cmd/scripts/NoSmoke/web/reports/2018-0-4-15:15:42-report.html reporter generated: /home/cmd/scripts/NoSmoke/web/reports/2018-0-4-15:15:42-report.html reporter generated: /home/cmd/scripts/NoSmoke/web/reports/2018-0-4-15:15:42-report.html reporter generated: /home/cmd/scripts/NoSmoke/web/reports/2018-0-4-15:15:42-report.html reporter generated: /home/cmd/scripts/NoSmoke/web/reports/2018-0-4-15:15:42-report.html reporter generated: /home/cmd/scripts/NoSmoke/web/reports/2018-0-4-15:15:42-report.html reporter generated: /home/cmd/scripts/NoSmoke/web/reports/2018-0-4-15:15:42-report.html

然后就是如此一直报该句 reporter generated: /home/cmd/scripts/NoSmoke/web/reports/2018-0-4-15:15:42-report.html 现象是并没优先 找到 常规注册 然后点击 就一直循环。 这是一个问题 。

另这份也无法跑通,这份的现象就是访问到百度 接下来 并不执行后续配置的遍历内容。

webTest.yml内容

1. Initialization option

desiredCapabilities:

Electron Configuration

platformName: 'Desktop' browserName: 'Electron' url: 'https://www.baidu.com'

2. Crawling option

crawlingConfig: platform: 'pc-web' targetElements: SearchConetent: actionType: 2 searchValue : 'kw' actionValue : '中文+Test+Nosmoke' Search: actionType: 1 searchValue : 'su' clickTypes:

macaca server Log: cmd@TR:~$ macaca server --verbose

index.js:18:12 [master] pid:25392 webdriver server start with config: { port: 3456, verbose: true, always: true, ip: '192.168.66.113', host: 'TR', loaded_time: '2018-01-04 15:19:49' } middlewares.js:17:10 [master] pid:25392 base middlewares attached router.js:133:10 [master] pid:25392 router set webdriver sdk launched responseHandler.js:11:12 [master] pid:25392 Recieve HTTP Request from Client[2018-01-04 15:20:10]: method: POST url: /wd/hub/session, jsonBody: {"desiredCapabilities":{"platformName":"Desktop","browserName":"Electron","url":"https://www.baidu.com"}} session.js:47:10 [master] pid:25392 Creating session, sessionId: 15883f93-9eca-40fc-b07c-f0efbd95ecc1. responseHandler.js:49:14 [master] pid:25392 Send HTTP Respone to Client[2018-01-04 15:20:13]: {"sessionId":"15883f93-9eca-40fc-b07c-f0efbd95ecc1","status":0,"value":"{\"platformName\":\"Desktop\",\"browserName\":\"Electron\",\"url\":\"https://www.baidu.com\"}"} responseHandler.js:11:12 [master] pid:25392 Recieve HTTP Request from Client[2018-01-04 15:20:13]: method: POST url: /wd/hub/session/15883f93-9eca-40fc-b07c-f0efbd95ecc1/url, jsonBody: {"url":"https://www.baidu.com"} responseHandler.js:49:14 [master] pid:25392 Send HTTP Respone to Client[2018-01-04 15:20:13]: {"sessionId":"15883f93-9eca-40fc-b07c-f0efbd95ecc1","status":0,"value":null} A Parser-blocking, cross site (i.e. different eTLD+1) script, http://s1.bdstatic.com/r/www/cache/static/global/js/all_async_search_f5b321b.js, is invoked via document.write. The network request for this script MAY be blocked by the browser in this or a future page load due to poor network connectivity. If blocked in this page load, it will be confirmed in a subsequent console message.See https://www.chromestatus.com/feature/5718547946799104 for more details. A Parser-blocking, cross site (i.e. different eTLD+1) script, http://s1.bdstatic.com/r/www/cache/static/global/js/all_async_search_f5b321b.js, is invoked via document.write. The network request for this script MAY be blocked by the browser in this or a future page load due to poor network connectivity. If blocked in this page load, it will be confirmed in a subsequent console message.See https://www.chromestatus.com/feature/5718547946799104 for more details. responseHandler.js:11:12 [master] pid:25392 Recieve HTTP Request from Client[2018-01-04 15:20:19]: method: GET url: /wd/hub/session/15883f93-9eca-40fc-b07c-f0efbd95ecc1/source, jsonBody: {} responseHandler.js:49:14 [master] pid:25392 Send HTTP Respone to Client[2018-01-04 15:20:19]: {"sessionId":"15883f93-9eca-40fc-b07c-f0efbd95ecc1","status":0,"value":"\"\n \n <meta http-equiv=\\"content-type\\" content=\\"text/html;charset=utf-8\\">\n <meta http-equiv=\\"X-UA-Compatible\\" content=\\"IE=Edge\\">\n\t<meta content=\\"always\\" name=\\"referrer\\">\n <meta name=\\"theme-color\\" content=\\"#2932e1\\">\n <link rel=\\"shortcut icon\\" href=\\"/favicon.ico\\" type=\\"image/x-icon\\">\n <link rel=\\"search\\" type=\\"application/opensearchdescr..."} responseHandler.js:11:12 [master] pid:25392 Recieve HTTP Request from Client[2018-01-04 15:20:19]: method: GET url: /wd/hub/session/15883f93-9eca-40fc-b07c-f0efbd95ecc1/url, jsonBody: {} responseHandler.js:49:14 [master] pid:25392 Send HTTP Respone to Client[2018-01-04 15:20:19]: {"sessionId":"15883f93-9eca-40fc-b07c-f0efbd95ecc1","status":0,"value":"\"http://www.baidu.com/\""} responseHandler.js:11:12 [master] pid:25392 Recieve HTTP Request from Client[2018-01-04 15:20:19]: method: GET url: /wd/hub/session/15883f93-9eca-40fc-b07c-f0efbd95ecc1/source, jsonBody: {} responseHandler.js:49:14 [master] pid:25392 Send HTTP Respone to Client[2018-01-04 15:20:19]: {"sessionId":"15883f93-9eca-40fc-b07c-f0efbd95ecc1","status":0,"value":"\"\n \n <meta http-equiv=\\"content-type\\" content=\\"text/html;charset=utf-8\\">\n <meta http-equiv=\\"X-UA-Compatible\\" content=\\"IE=Edge\\">\n\t<meta content=\\"always\\" name=\\"referrer\\">\n <meta name=\\"theme-color\\" content=\\"#2932e1\\">\n <link rel=\\"shortcut icon\\" href=\\"/favicon.ico\\" type=\\"image/x-icon\\">\n <link rel=\\"search\\" type=\\"application/opensearchdescr..."} responseHandler.js:11:12 [master] pid:25392 Recieve HTTP Request from Client[2018-01-04 15:20:19]: method: GET url: /wd/hub/session/15883f93-9eca-40fc-b07c-f0efbd95ecc1/url, jsonBody: {} responseHandler.js:49:14 [master] pid:25392 Send HTTP Respone to Client[2018-01-04 15:20:19]: {"sessionId":"15883f93-9eca-40fc-b07c-f0efbd95ecc1","status":0,"value":"\"http://www.baidu.com/\""} responseHandler.js:11:12 [master] pid:25392 Recieve HTTP Request from Client[2018-01-04 15:20:25]: method: GET url: /wd/hub/session/15883f93-9eca-40fc-b07c-f0efbd95ecc1/source, jsonBody: {} responseHandler.js:49:14 [master] pid:25392 Send HTTP Respone to Client[2018-01-04 15:20:25]: {"sessionId":"15883f93-9eca-40fc-b07c-f0efbd95ecc1","status":0,"value":"\"\n \n <meta http-equiv=\\"content-type\\" content=\\"text/html;charset=utf-8\\">\n <meta http-equiv=\\"X-UA-Compatible\\" content=\\"IE=Edge\\">\n\t<meta content=\\"always\\" name=\\"referrer\\">\n <meta name=\\"theme-color\\" content=\\"#2932e1\\">\n <link rel=\\"shortcut icon\\" href=\\"/favicon.ico\\" type=\\"image/x-icon\\">\n <link rel=\\"search\\" type=\\"application/opensearchdescr..."} responseHandler.js:11:12 [master] pid:25392 Recieve HTTP Request from Client[2018-01-04 15:20:25]: method: GET url: /wd/hub/session/15883f93-9eca-40fc-b07c-f0efbd95ecc1/url, jsonBody: {} responseHandler.js:49:14 [master] pid:25392 Send HTTP Respone to Client[2018-01-04 15:20:25]: {"sessionId":"15883f93-9eca-40fc-b07c-f0efbd95ecc1","status":0,"value":"\"http://www.baidu.com/\""}

nosmoke Log: cmd@TR:~/scripts/NoSmoke/web$ nosmoke -c webTest.yml --verbose

server.js:15:12 [master] pid:25447 server start with config: { port: 5678, verbose: true, config: 'webTest.yml', ip: '192.168.66.113', host: 'TR', loaded_time: '2018-01-04 15:20:09' } udid: undefined (node:25447) DeprecationWarning: 'root' is deprecated, use 'global' <-- GET / reporter generated: /home/cmd/scripts/NoSmoke/web/reports/2018-0-4-15:20:9-report.html --> GET / 200 initialize crawler reporter generated: /home/cmd/scripts/NoSmoke/web/reports/2018-0-4-15:20:9-report.html { raw: 'a href="/" id="result_logo" onmousedown="return c({\'fm\':\'tab\',\'tab\':\'logo\'})"', data: 'a href="/" id="result_logo" onmousedown="return c({\'fm\':\'tab\',\'tab\':\'logo\'})"', type: 'a', name: 'a', attribs: { href: '/', id: 'result_logo', onmousedown: 'return c({\'fm\':\'tab\',\'tab\':\'logo\'})' } } { raw: 'input type="hidden" name="ie" value="utf-8"', data: 'input type="hidden" name="ie" value="utf-8"', type: 'input', name: 'input', attribs: { type: 'hidden', name: 'ie', value: 'utf-8' }, input: 'random+123' } { raw: 'input type="hidden" name="f" value="8"', data: 'input type="hidden" name="f" value="8"', type: 'input', name: 'input', attribs: { type: 'hidden', name: 'f', value: '8' }, input: 'random+123' } reporter generated: /home/cmd/scripts/NoSmoke/web/reports/2018-0-4-15:20:9-report.html ^C

SamuelZhaoY commented 6 years ago

https://github.com/macacajs/NoSmoke/blob/master/lib/crawler/web.js#L31 @Archer456 看一下这个地方, 可能会有特定格式的链接没有被检索到, 如果检索到了 会执行跳转的