Appium Appium 在 MAC OS X 中如何安装及使用?

Anson · 2013年10月24日 · 最后由 Anson 回复于 2017年05月07日 · 3864 次阅读

Appium 在 MAC OS X 中如何安装及使用?

在 appium 网页中下载了 appium.app 直接运行后,如何测试一个已经做好的 android 安装文件 apk?
或者说,如何跑 appium 的 sample? 貌似找不到 appium 的工作目录及工作目录没有其他文件和文件夹。

共收到 38 条回复 时间 点赞

加个头像吧~ 而且你的名字怎么都是数字啊。。。

其实 我在这篇里 http://testerhome.com/topics/136 有提到一点,不过具体可能需要做个入门的教程。。

我试验了下,把我的步骤贴上来。

安装 appium:

> sudo npm install -g appium
> npm install wd
> appium &
> node your-appium-test.js

下载源码,用里面的 example

git clone https://github.com/appium/appium.git

➜  sample-code git:(master)# 到 appium 虾米的 sample code 下面
/Users/lihuazhang/appium/sample-code
➜  sample-code git:(master)ls
apps     examples
➜  sample-code git:(master)cd apps/TestApp/
➜  TestApp git:(master) ✗ xcodebuild -sdk iphonesimulator6.0 # 生成 build/Test.app

然后运行:

python examples/python/simple.py

确保 appium 服务启动着。

simple.py 的 setUp 方法里全写好了。

def setUp(self):
      # set up appium
      app = os.path.join(os.path.dirname(__file__),
                         '../../apps/TestApp/build/Release-iphonesimulator',
                         'TestApp.app')
      app = os.path.abspath(app)
      self.driver = webdriver.Remote(
          command_executor='http://127.0.0.1:4723/wd/hub',
          desired_capabilities={
              'browserName': 'iOS',
              'platform': 'Mac',
              'version': '6.0',
              'app': app
          })
      self._values = []


只是 node 的一个 npm 包,建议你看看官方的文档。
存放位置和 node 的配置相关。

如何测试的话,看看其其他的帖子,参考下

http://appium.io/zh-cn/index.html 用 nodejs 安装比较好。

#1 楼 @lihuazhang

名字是我的 qq 号。

#5 楼 @532589730 你试验成功了没? 能跑起来 sample code 么?

#6 楼 @lihuazhang
不好意思,刚开始用 MAC,而且之前没有做过移动程序方面的测试,所以现在还在摸索中。
呵呵,现在跑完 sudo npm install -g appium,安装 appium 后的文件夹在哪都不知道。

#8 楼 @lihuazhang
已更换

#7 楼 @532589730 nodejs 的 npm 安装你可以了解下:

安装模块只需要 npm install express connect 命令给我们带来了很大的方便。安装模块的路径分两种:

全局路径,也就是带上参数 -g 的安装模式。这个命令会把模块安装在 $PREFIX/lib/node_modules 下,可通过命令 npm root -g 查看全局模块的安装目录。 package.json 里定义的 bin 会安装到 $PREFIX/bin 目录下,如果模块带有 man page 会安装到 $PREFIX/share/man 目录下。
本地路径,不带 -g 参数的。从当前目录一直查找到根目录/下有没有 node_modules 目录,有模块安装到这个目录下的 node_modules 目录里,如果没有找到则把模块安装到当前目录 node_modules 目录下。package.josn 定义的 bin 会安装到 node_modules/.bin 目录下,man page 则不会安装。

要获得 appium 的源码你需要 clone 他们的项目。 https://github.com/appium/appium

#7 楼 @532589730 就是说你不需要知道 appium 安装在哪里, 你只要在命令行能用 appium 的命令就可以了。

Anson #12 · 2013年10月25日 Author

sudo npm install -g appium
npm install wd

上面两句已经跑完了,现在死在"appium &"上了,提示下面的错误:
error: Could not find config file; looks like config hasn't been run! Please run reset.sh or appium configure.

我 clone 了 appium 的项目,解压后出来后发现一个 reset.sh 的 shell 脚本,于是我跑这个脚本./reset.sh,出现错误提示如下:
bash-3.2$ ./reset.sh
---- Resetting / Initializing Appium ----
RESETTING NPM

  • Clearing out old .appiumconfig
  • Installing new or updated NPM modules
  • Setting git revision data RESETTING IOS
  • Cloning/updating instruments-without-delay
  • Building instruments-without-delay ---- FAILURE: reset.sh exited with status 1 ---- ---- Retry with --verbose to see errors ----
Anson #25 · 2013年10月25日 Author

#13 楼 @lihuazhang
谢谢 lihuazhang,我先看看

Anson #15 · 2013年10月25日 Author

#13 楼 @lihuazhang
按照 post 说的卸载了 appium 和重新安装了 appium(-g 全局),仍然无法解决问题。

#15 楼 @532589730 你 xcode 的 command line tool 安装了没?

Anson #22 · 2013年10月25日 Author

#16 楼 @lihuazhang
刚才看了下,xcode 中还真没有这个 command line tool 组件,正在下载中。

不用 clone 吧,只需要安装 node,使用 npm install appium 就可以了。
然后启动 appium 即可

Anson #19 · 2013年10月25日 Author

#18 楼 @seveniruby
node 已经安装好了,现在问题是出在安装完 appium 后,appium 无法启动。

#19 楼 @532589730 建议你重新安装下,没有 command line tools, 估计 nodejs 之类的都没有装好。

Anson #21 · 2013年10月25日 Author

#20 楼 @lihuazhang
node 是 pkg 安装的,要卸载的话,怎么卸载?
在 applications 中没有看到有 node

#21 楼 @532589730 再装一遍就成了吧。 试试看,这倒是没遇到过。

Anson #23 · 2013年10月25日 Author

#22 楼 @lihuazhang
谢谢!! 电脑正在 upgrade xcode,command 刚才安装了,xcode 升级完后再重新安装一下。

#23 楼 @532589730 恩 推荐用最新的。

Anson #14 · 2013年10月25日 Author

#24 楼 @lihuazhang
是的,最新的 mac 10.9 和 xcode 5.0.1

Anson #13 · 2013年10月25日 Author

#24 楼 @lihuazhang
Hello lihuazhang,安装完 command line tools 后,在 xcode 中还是看不到 command line tools 组件,这样有问题么?

#26 楼 @532589730 装好就可以了吧。 看看 git svn 这种命令。

Anson #28 · 2013年10月25日 Author

#27 楼 @lihuazhang
敲完 git svn 后,出来类似帮助说明的结果。
git svn
git-svn - bidirectional operations between a single Subversion tree and git
usage: git svn [options] [arguments]

Available commands:
blame Show what revision and author last modified each line of a file
--git-format
branch Create a branch in the SVN repository
--commit-url
--destination, -d
--dry-run, -n
--message, -m
--parents
--tag, -t
--username
clone Initialize and fetch revisions

#28 楼 @532589730 那你应该已经装好了 command line tool 了。

#29 楼 @lihuazhang
 重新安装了 appium,在 appium&还是出现了先前的错误信息

#30 楼 @532589730 加我 qq 87294417, 我们讨论下。。

@532589730 ,你好,我问个比较二的问题哈,命令行 npm 安装的 appium 怎么打开图形界面啊

#32 楼 @xuelily1
很久以前的问题了。
以前的 appium 安装并没有现在这么顺利,在 terminal 中安装会碰到不同的问题。

Anson #34 · 2016年02月28日 Author

#32 楼 @xuelily1 appium 图形界面,安装 dmg 就有了。

#32 楼 @xuelily1 npm 安装的,应该没有图形界面的

Mac pro 命令安装提示这个。app 安装要怎么配置呢
npm install appium
npm WARN deprecated win-spawn@2.0.0: use cross-spawn or cross-spawn-async instead.
⸨ ░░░░░░░░░░░░░░⸩ ⠦ fetchMetadata: http fetch 200 https://registry.npmjs.org/appium-uiau

@532589730 你好,看到您回复 #32 的消息,意思是不是 npm 安装完之后,还需要下载安装 dmg 呢?这样不就有两个服务了吗?还是说如果只要图形界面的,就只安装 dmg 就可以了呢? 大神求解~

Anson #38 · 2017年05月07日 Author
哆啦JJ 回复

这篇文章好久的了。
appium 支持多 server 模式,即使是 command line 都可以开启多个 appium server,只要 port 不一样就可以。
故 command line appium 和 GUI appium 是没有冲突的。

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