看代码注释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. osgQt支持触摸屏

    1. osgQt的构造函数添加:setAttribute(Qt::WA_AcceptTouchEvents);//wyh 2. event()修改,支持触摸时间 bool GLWidget::even ...

  2. org.eclipse.wst.common.project.facet.core.xml

    Ctrl+Shift+R    *core.xml 修改Dynamic Web module 由3.1 切至2.几

  3. 基于Xcode5的本地化

    一.程序名国际化   1.首先添加应用对多语言支持的国际化文件   点击工程根目录,然后选择PROJECT下的项目,然后选择Info选项卡,在底部可以看到Localizations,点击“+”号,可以 ...

  4. 学习tomcat(一)----用IDEA调试tomcat源码

    一直在使用tomcat,但却不怎么熟悉tomcat的"运作流程",今天就 参照参考文章进行了代码搭建(代码的github在文末),并修改了一些操作.学习下tomcat的" ...

  5. Vue.js的库,包,资源的列表大全。

    官方资源 外部资源 社区 播客 官方示例 入门 开发工具 语法高亮 代码片段 自动补全 组件集合 库和插件 路由 ajax/数据 状态管理 校验 UI组件 i18n 示例 模板 脚手架 整合 插件/指 ...

  6. javascript高级程序设计读书笔记----严格模式

    ECMAScript5最早引入“严格模式". 使用 "use strict"开启严格模式 function test(){ "use strict"; ...

  7. C#统计英文文本中的单词数并排序

    思路如下:1.使用的Hashtable(高效)集合,记录每个单词出现的次数2.采用ArrayList对Hashtable中的Keys按字母序排列3.排序使用插入排序(稳定) public void S ...

  8. c++调用c#写的DLL

    c++调用c#写的DLL: 此文章演示了建立c#的dll: c++建立工程,引入dll: 不能解决的问题: 指定dll的路径,在代码里面直接写 #using "xxx.dll" 必 ...

  9. 4.Python的版本

    Python2: 英文支持没问题,中文报错,默认编码:ascii码 显示中午需要添加代码在首行:# -*- encoding:utf -8 -*- 用户交互  raw_input python2 里还 ...

  10. APIO2012 派遣dispatching | 左偏树

    题目链接:戳我 就是尽可能地选取排名小的,加起来就可以了.然后我们考虑利用一个大根堆,一个一个合并,如果超过派遣的钱,我们就把费用最大的那个忍者丢出队列. 左偏树,作为一个十分优秀的可并堆,我们这道题 ...