Calabash Calabash-ios framework 的安装过程

西门吹牛 · 2014年09月11日 · 最后由 恒温 回复于 2014年09月11日 · 1417 次阅读

IOS 的比 Android 难一些,主要是需要配置 framework,其他都差不多,这方面资料比较少,很多英文的有不太好啃,用这个工具的也比较少,可能 android 上用的相对多一点,因为公司项目不太适合 Appium,自己琢磨着用 Calabash,分享下过程吧。
先参考这篇文章
https://github.com/calabash/calabash-ios
主要是按照这个的步骤一步一步来的,如果你对 Xcode 熟悉,这些都不在话下,如果不熟,请教下开发,文档的 xcode 版本过低,很多页面跟实际还是有些不同。
http://www.moncefbelyamani.com/ios-automated-testing-with-calabash-cucumber-ruby/

  1. 装 Ruby 的环境和跑用例我就不讲了。 大概: cd path-to-my-ios-project gem install calabash-cucumber calabash-ios setup calabash-ios gen cucumber

例子很简单,但是你要做自己的项目,就需要定位元素吧。
如果你按照 Android 的方法,
calabash-ios console
start_test_server_in_background
出错信息会告诉你环境不行,framework 没装之类的错误。

怎么办,看哥哥细细道来:
步骤 1:
Install the calabash-cucumber gem
$ gem install calabash-cucumber
步骤 2:
在 targets 下把项目 Duplicate 一个,主要用来测试
under TARGETS, and select Duplicate. Or, simply click on newsyc and press ⌘D. If you get a Duplicate iPhone Target prompt, click on the Duplicate Only button.
然后改名,如:newsyc-calabash
1,需要在 targets 里面改名
2,需要在 Manage Schemes 里面改名
3,需要在 Build Settings 里面改名

步骤 2:

  1. 下载一个 calabash.framework, 按照这个文档,源文件已经被删除。 幸好还有 git 的文档, 用这个命令下载: calabash-ios download 然后把这个文件拖到 xcode 项目里面。
  2. 加 CFNetwork.framework 在复制的那个项目中,click on Build Phases, expand Link Binary with Libraries, click on +, click on CFNetwork.framework, and click on Add
  3. 配置 Other Linker Flags
    选中你复制的项目,Click on Build Settings, click on All (if it’s not already selected), then search for other linker, click on the Other Linker Flags row, then click once under Yes to enable edit mode,
    and copy and paste the following: -force_load "$(SRCROOT)/calabash.framework/calabash" -lstdc++. Click anywhere outside of the text field to save your changes.
    You should end up with something like this (note that what appears after -force_load will be different for you since that is the path to your project on your computer).

  4. 开测
    在测得过程中,打开 console output

首先看下元素能否定位了:

再写 case 啥的已经不在话下了。
OK,搞定,先回家,明天可以大搞了。

共收到 1 条回复 时间 点赞

内容不错, 排版略粗糙啊。。

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册