看代码注释todo
写博客


服务写脚本开吧 , 因为窗口太多,  不知道要去哪关闭服务
开的话无所谓 , 哪里都能开
要确认是否有开 , 直接跑代码


下面的要先过


别人的环境






工具软件自己的问题



不支持面向页面设计模式 , 更不用说面向组件
没有任何注解

官方文档严重缺失 , 只给了 API , 没有更详细的例子



等待机制 , 比如 等待元素出现 , 这个文档里我没看到 , 有知道这个的吗 . 类似 waitUntil( 元素定位器  )


阿里开源的
官网
https://macacajs.com/quick-start

官方例子
https://github.com/macacajs/macaca-test-sample

使用例子的步骤
git clone https://github.com/macaca-sample/sample-nodejs.git --depth=1
cd sample-nodejs
npm i
make

参考文章
http://www.cnblogs.com/fnng/p/5873878.html

搭建环境

前提
node版本 6 以上
安装cnpm , 这样安装很快

安装 macaca-cli 命令行工具
npm install  -g macaca-cli

安装成功 :
macaca -v
2.0.4

npm install -g  macaca
输出  macaca@1.0.0


安装 谷歌浏览器 的驱动
cnpm install macaca-chrome -g
成功 :
 

安装 webdriver-client
cnpm install webdriver-client -g
成功 :
 

安装 macaca-electron  可选
cnpm install macaca-electron -g
成功 :
C:\Windows\system32>cnpm install macaca-electron -g
Downloading macaca-electron to C:\Users\zhangqiang\AppData\Roaming\npm\node_modules\macaca-electron_tmp
Copying C:\Users\zhangqiang\AppData\Roaming\npm\node_modules\macaca-electron_tmp\_macaca-electron@1.1.6@macaca-electron to C:\Users\zhangqiang\AppData\Roaming\npm\node_modules\macaca-electron
Installing macaca-electron's dependencies to C:\Users\zhangqiang\AppData\Roaming\npm\node_modules\macaca-electron/node_modules
[1/7] co@^4.6.0 installed at node_modules\_co@4.6.0@co
[2/7] webdriver-dfn-error-code@^1.0.3 installed at node_modules\_webdriver-dfn-error-code@1.0.4@webdriver-dfn-error-code
[3/7] driver-base@^0.1.0 installed at node_modules\_driver-base@0.1.4@driver-base
[4/7] xlogger@^1.0.0 installed at node_modules\_xlogger@1.0.6@xlogger
[5/7] selenium-atoms@~1.0.1 installed at node_modules\_selenium-atoms@1.0.2@selenium-atoms
[6/7] electron-prebuilt@^0.37.6 installed at node_modules\_electron-prebuilt@0.37.8@electron-prebuilt
[7/7] macaca-utils@~0.1.8 installed at node_modules\_macaca-utils@0.1.9@macaca-utils
execute post install 1 scripts...
[1/1] scripts.postinstall electron-prebuilt@^0.37.6 run "node install.js"
Downloading electron-v0.37.8-win32-x64.zip
[============================================>] 100.0% of 49.65 MB (4.84 MB/s)
[1/1] scripts.postinstall electron-prebuilt@^0.37.6 finished in 23s
Recently updated (since 2017-06-19): 3 packages (detail see file C:\Users\zhangqiang\AppData\Roaming\npm\node_modules\macaca-electron\node_modules\.recently_updates.txt)
2017-06-23
→ electron-prebuilt@0.37.8 › extract-zip@1.6.5 › concat-stream@1.6.0 › readable-stream@2.3.2 › string_decoder@~1.0.0(1.0.3) (02:36:15)
2017-06-22
→ electron-prebuilt@0.37.8 › extract-zip@1.6.5 › concat-stream@1.6.0 › readable-stream@^2.2.2(2.3.2) (21:48:21)
→ electron-prebuilt@0.37.8 › extract-zip@1.6.5 › concat-stream@1.6.0 › readable-stream@2.3.2 › safe-buffer@~5.1.0(5.1.1) (04:19:28)
All packages installed (166 packages installed from npm registry, used 37s, speed 81.41kB/s, json 183(271.17kB), tarball 2.66MB)
[2/7] webdriver-dfn-error-code@^1.0.3 installed at node_modules\_webdriver-dfn-error-code@1.0.4@webdriver-dfn-error-code
[3/7] driver-base@^0.1.0 installed at node_modules\_driver-base@0.1.4
x
1
C:\Windows\system32>cnpm install macaca-electron -g
2
Downloading macaca-electron to C:\Users\zhangqiang\AppData\Roaming\npm\node_modules\macaca-electron_tmp
3
Copying C:\Users\zhangqiang\AppData\Roaming\npm\node_modules\macaca-electron_tmp\_macaca-electron@1.1.6@macaca-electron to C:\Users\zhangqiang\AppData\Roaming\npm\node_modules\macaca-electron
4
Installing macaca-electron's dependencies to C:\Users\zhangqiang\AppData\Roaming\npm\node_modules\macaca-electron/node_modules
5
[1/7] co@^4.6.0 installed at node_modules\_co@4.6.0@co
6
[2/7] webdriver-dfn-error-code@^1.0.3 installed at node_modules\_webdriver-dfn-error-code@1.0.4@webdriver-dfn-error-code
7
[3/7] driver-base@^0.1.0 installed at node_modules\_driver-base@0.1.4@driver-base
8
[4/7] xlogger@^1.0.0 installed at node_modules\_xlogger@1.0.6@xlogger
9
[5/7] selenium-atoms@~1.0.1 installed at node_modules\_selenium-atoms@1.0.2@selenium-atoms
10
[6/7] electron-prebuilt@^0.37.6 installed at node_modules\_electron-prebuilt@0.37.8@electron-prebuilt
11
[7/7] macaca-utils@~0.1.8 installed at node_modules\_macaca-utils@0.1.9@macaca-utils
12
execute post install 1 scripts...
13
[1/1] scripts.postinstall electron-prebuilt@^0.37.6 run "node install.js"
14
Downloading electron-v0.37.8-win32-x64.zip
15
[============================================>] 100.0% of 49.65 MB (4.84 MB/s)
16
[1/1] scripts.postinstall electron-prebuilt@^0.37.6 finished in 23s
17
Recently updated (since 2017-06-19): 3 packages (detail see file C:\Users\zhangqiang\AppData\Roaming\npm\node_modules\macaca-electron\node_modules\.recently_updates.txt)
18
  2017-06-23
19
    → electron-prebuilt@0.37.8 › extract-zip@1.6.5 › concat-stream@1.6.0 › readable-stream@2.3.2 › string_decoder@~1.0.0(1.0.3) (02:36:15)
20
  2017-06-22
21
    → electron-prebuilt@0.37.8 › extract-zip@1.6.5 › concat-stream@1.6.0 › readable-stream@^2.2.2(2.3.2) (21:48:21)
22
    → electron-prebuilt@0.37.8 › extract-zip@1.6.5 › concat-stream@1.6.0 › readable-stream@2.3.2 › safe-buffer@~5.1.0(5.1.1) (04:19:28)
23
All packages installed (166 packages installed from npm registry, used 37s, speed 81.41kB/s, json 183(271.17kB), tarball 2.66MB)


最后检查所有已经安装的  macaca doctor
不是 dockor 或 docter

2017-11-24 最新截图 , 新电脑 :




运行


第一个测试代码

运行前说一下注意事项 : 
1 , 命令在 macaca-test 文件夹的上一级目录 运行
2 , 因为命令只运行当前面目录下的 macaca-test 文件夹下的所有 .js 文件( 文件名随意 , 后缀是 .js 就行 ) , 所以自己写的测试代码只能放到 macaca-test 文件夹下 . 
下面是文件放在 macaca-test 文件夹下 , 但在当前文件夹执行命令 的报错
 
新的运行方式 :

先把服务运行起来 , 不然会报错
macaca server
 没服务的话会报错 :
 
 
git clone https://github.com/macaca-sample/sample-java.git

到入到IDEA


运行并看控制台
 

成功
 


 

问题







最新的环境  2017-07-27
 


似乎安装浏览器驱动失败

找不到 macha 框架

 npm install --global mocha
安装成功后还是不行
依赖包的路径是错的 , 把自己的测试文件 移动到外面一层

在项目路径里找不到  webdriver-client

 

分析
虽然我全局安装了 , 但它只在项目路径里找这个

解决方案
再安装
cnpm install webdriver-client --save-dev
 

macaca run 怎么指定运行哪个测试 js 文件

macaca run a.js  无效

无效的文件名
my-desktop.test.js
my-desktop-1.test.js


com.alibaba.fastjson.JSONException: syntax error, pos 1, json : Internal Server Error

主要是看 服务那边的报错
Cannot find module 'macaca-android' , 原因是本地没有安装 android的环境
Error: >> session.js:40:14 [master] pid:19012 Error: Cannot find module 'macaca-android'
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
Cannot find module 'macaca-android'
x
1
Error: >> session.js:40:14 [master] pid:19012 Error: Cannot find module 'macaca-android'
2
    at Function.Module._resolveFilename (module.js:536:15)
3
    at Function.Module._load (module.js:466:25)


java.lang.Exception: An element command could not be completed because the element is not visible on the page.






Macaca 等待机制的更多相关文章

  1. WebDriver元素等待机制

    能否构建健壮和可靠的测试是UI自动化测试能否成功的关键因素之一.但实际情况是当一个测试接着一个测试执行的时候,常会遇到各种不同的状况.比如脚本去定位元素或去验证程序的运行状态时,有时会发现找不到元素, ...

  2. Python+Selenium笔记(十):元素等待机制

     (一) 前言 突然的资源受限或网络延迟,可能导致找不到目标元素,这时测试报告会显示测试失败.这时需要一种延时机制,来使脚本的运行速度与程序的响应速度相匹配,WebDriver为这种情况提供了隐式等待 ...

  3. selenium等待机制

    等待机制 ​ 因为你要查找的标签由于网速等原因迟迟没有加载出来,你就直接获取这个标签,很明显是报错,现有的简单粗暴的解决办法就是time.sleep(3),睡几秒,也就是设置线程等待,等这个标签加载出 ...

  4. selenium WebDriverWait类等待机制的实现

    在自动化测试脚本的运行过程中,可以通过设置等待的方式来避免由于网络延迟或浏览器卡顿导致的偶然失败,常用的等待方式有三种: 很多人学习python,不知道从何学起.很多人学习python,掌握了基本语法 ...

  5. selenium等待机制学习笔记

    转载至: https://blog.csdn.net/huilan_same/article/details/52544521 1. 强制等待 第一种也是最简单粗暴的一种办法就是强制等待sleep(x ...

  6. appnium显式等待机制

    强制等待: sleep不推荐全局隐式等待 全局隐式等待: 在服务端等待 driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); ...

  7. selenium(Java)WebDriverWait等待机制

    //标题是不是“百度一下,你就知道” 18 new WebDriverWait(driver,5).until(ExpectedConditions.titleIs("百度一下,你就知道&q ...

  8. 再谈AbstractQueuedSynchronizer:共享模式与基于Condition的等待/通知机制实现

    共享模式acquire实现流程 上文我们讲解了AbstractQueuedSynchronizer独占模式的acquire实现流程,本文趁热打铁继续看一下AbstractQueuedSynchroni ...

  9. 再谈AbstractQueuedSynchronizer2:共享模式与基于Condition的等待/通知机制实现

    共享模式acquire实现流程 上文我们讲解了AbstractQueuedSynchronizer独占模式的acquire实现流程,本文趁热打铁继续看一下AbstractQueuedSynchroni ...

随机推荐

  1. idea 启动报错问题

    Artifact SpiderServer:war exploded: Error during artifact deployment. See server log for details. 1. ...

  2. Linux查询系统信息命令

    Linux查看系统信息是比较基础的知识,所以这个应该都需要掌握,命令和解释如下: #uname -a           查看操作系统.内核.CPU信息 #head -n 1 /etc/issue   ...

  3. C# Timer 用法

    System.Timers.Timer,通过.NET  Thread  Pool实现的,轻量,计时精确,对应用程序.消息没有特别的要求. using Timer = System.Timers.Tim ...

  4. SIP协议整理

    本文记录开发.实现IMS项目时,整理的SIP协议基础知识:若有侵权,请告之. SIP协议 1.      SIP协议简介 SIP是一个应用层的控制协议,可以用来建立.修改.和终止多媒体会话(或者会议) ...

  5. JAVA并发设计模式学习笔记(二)—— Single Threaded Execution Pattern

    注:本文的主要参考资料为结城浩所著<JAVA多线程设计模式>. 单线程执行模式(Single Threaded Execution Pattern)是最简单的多线程设计模式,几乎所有其他的 ...

  6. Atcoder 2566 3N Numbers(优先队列优化DP)

    問題文N を 1 以上の整数とします. 長さ 3N の数列 a=(a1,a2,…,a3N) があります. すぬけ君は.a からちょうど N 個の要素を取り除き.残った 2N 個の要素を元の順序で並べ. ...

  7. 【Web学习笔记】浅析CGI概念及用法

    1. CGI是什么         CGI是Common Gateway Interface的简写,它提供了一种标准方法使得位于WebServer后端的web应用可以根据client的请求动态生成网页 ...

  8. myeclipse设置默认的jsp打开方式

  9. [LeetCode 题解]: Two Sum

    前言   [LeetCode 题解]系列传送门:  http://www.cnblogs.com/double-win/category/573499.html   1.题目描述 Given an a ...

  10. ZKEACMS 2.2.1 正式发布,更多特性等您来发现

    前言 如果你还不知道ZKEACMS,不妨先了解一下. ASP.NET MVC 开源建站系统 ZKEACMS 推荐,从此网站“拼”起来 官方地址:http://www.zkea.net/zkeacms ...