Appium Appium 怎么在 Windows 上运行呢

Shery · 2013年11月07日 · 最后由 meimeiyuyun 回复于 2013年12月06日 · 2026 次阅读

我下载了 AppiumForWindows-0.11.2,配置了 Android 的环境,安装了 Apache ANT、Maven 和 Git。
打开文件夹中的 Appium.exe,显示了 Appium 的运行 GUI 界面,可是接下来要怎么做呢,怎么运行 Python 脚本呢???
急求帮助啊!谢谢

共收到 50 条回复 时间 点赞

加个头像吧

运行起来,然后跑测试

可是要怎么运行 Python 脚本呢

#4 楼 @shery_zhang2012 http://testerhome.com/topics/182 这里有说,其实就是普通的 python 的普通脚本啦

手机连接上以后,为什么在 launch avd 中检测不到呢

#6 楼 @shery_zhang2012 什么手机? 看看 adv devices -l 有没有,如果没有,可能认不出手机的 vender id ,那按照http://testerhome.com/topics/153 这个帖子来

现在网络不好,晚上在家头像_

你得先充电下对应的知识, adb selenium remote webdirver
@lihuazhang 看来做视频也是必要的,呵呵

Shery #11 · 2013年11月07日 Author

我是一个菜鸟,觉得这个工具很强大,想研究一下它,可是看了资料仍然不知道是怎么用的。

#11 楼 @shery_zhang2012 慢慢来, 不止是这个工具, android 的测试工具都有类似的复杂问题, 小白入门不易, 需要不断摸索, 先提前系统的学习下部分的知识吧, 比如没有这个工具, 如何识别虚拟机和手机的连接, 以及他们的机制等. 我也是买了好几本书学 android

国内对于 android 测试的框架研究还不错, 百度基本没戏, google 还好些.

Shery #13 · 2013年11月07日 Author

谢谢 seveniruby 12 楼 还会继续努力

Shery #14 · 2013年11月07日 Author

8 楼 @lihuazhang ,可以咨询几个问题吗?
1、怎么启动 Appium 的 server 呢?
2.在 windows 上一定要用 NPM 命令行安装 Appium 吗?直接点击文件夹中的 Appium.exe 不可以吗?
3.在 Windows 安装说明里有一个运行 reset.bat 这个文件请问在那个文件里呢?
4、安装文件中说 “要在 windows 上运行测试用例,你需要先启动 Android 模拟器或者连接上一个 API Level17 以上的 android 真机。
然后在命令行运行 appium
node .
” 这个输入 appium 是任意一个命令行还是在 Git 的命令行里呢?

@shery_zhang2012 今天刚试过,我是用的 python 运行的,在 windows 下,直接在 cmd 命令行运行 appium,然后再开一个 cmd,执行 python 脚本就可以成功运行了,如果 python 运行出现问题,可以参考下面文章解决http://testerhome.com/topics/182, 目前只尝试成功 python 的,其他的还没有试

Shery #16 · 2013年11月08日 Author

#15 楼 rabbit 我运行了 appium,提示找不到该命令,我在想 appium 一定要使用 npm 安装吗?

#16 楼 @shery_zhang2012 我试了 2 种方法安装,第一种你如果用命令启动 appium,找不到那就是你没安装,你可以用 npm 安装,第二种,你可以下载 appium.exe,界面版的 appium,然后打开 appium.exe,也是可以启动的。

#16 楼 @shery_zhang2012 找不到,可能是环境变量的问题。

Shery #19 · 2013年11月08日 Author

#17 楼 rabbit 我运行了 Appium.exe,但是在对话框下面并没有 Nodejs 的那个框,检查了一下 nodejs 确实安装上了,这是为什么呢?

#19 楼 @shery_zhang2012 你点击 Appium.exe 只是启动了 appium,nodeJs 需要点击 node.exe 或者去命令里面,输入 node(前提是环境配置好)即可以,这是 2 个东西,是需要分别启动的

Shery #21 · 2013年11月08日 Author

#20 楼 rabbit 我运行 python 的脚本时,出现了 ImportError: No module named 'selenium',难道 selenium 还需要自己下载安装吗?

#21 楼 @shery_zhang2012
是的,你参考http://testerhome.com/topics/182 这个页面下面的安装就可以了

Shery #23 · 2013年11月08日 Author

在运行 Python 文件的时候,遇到这样的问题:

F:\Program Files>python appium-0.11.3\appium-0.11.3\sample-code\examples\python\
android_contacts.py
Traceback (most recent call last):
File "appium-0.11.3\appium-0.11.3\sample-code\examples\python\android_contacts
.py", line 17, in
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
File "F:\Program Files\python\lib\site-packages\selenium-2.37.2-py3.3.egg\sele
nium\webdriver\remote\webdriver.py", line 71, in init
self.start_session(desired_capabilities, browser_profile)
File "F:\Program Files\python\lib\site-packages\selenium-2.37.2-py3.3.egg\sele
nium\webdriver\remote\webdriver.py", line 113, in start_session
'desiredCapabilities': desired_capabilities,
File "F:\Program Files\python\lib\site-packages\selenium-2.37.2-py3.3.egg\sele
nium\webdriver\remote\webdriver.py", line 162, in execute
response = self.command_executor.execute(driver_command, params)
File "F:\Program Files\python\lib\site-packages\selenium-2.37.2-py3.3.egg\sele
nium\webdriver\remote\remote_connection.py", line 355, in execute
return self._request(url, method=command_info[0], data=data)
File "F:\Program Files\python\lib\site-packages\selenium-2.37.2-py3.3.egg\sele
nium\webdriver\remote\remote_connection.py", line 402, in _request
response = opener.open(request)
File "F:\Program Files\python\lib\urllib\request.py", line 469, in open
response = self._open(req, data)
File "F:\Program Files\python\lib\urllib\request.py", line 487, in _open
'_open', req)
File "F:\Program Files\python\lib\urllib\request.py", line 447, in _call_chain

result = func(*args)
File "F:\Program Files\python\lib\urllib\request.py", line 1268, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "F:\Program Files\python\lib\urllib\request.py", line 1253, in do_open
r = h.getresponse()
File "F:\Program Files\python\lib\http\client.py", line 1143, in getresponse
response.begin()
File "F:\Program Files\python\lib\http\client.py", line 354, in begin
version, status, reason = self._read_status()
File "F:\Program Files\python\lib\http\client.py", line 324, in _read_status
raise BadStatusLine(line)
http.client.BadStatusLine: ''

请问这是什么原因呢?

24楼 已删除

良好的讨论,有所结果,别忘记分享出来。

#24 楼 @rabbit 私聊这种事情不鼓励啊

#26 楼 @seveniruby 在这上面沟通太慢了,等我们沟通出来结果,在放这上面。。一样一样滴~~呵呵

#27 楼 @rabbit 我的意思是, 别人愿意在论坛上回复, 是因为他有时间, 并不代表任何时间他都 ok. 直接 qq 聊天容易给别人带来干扰, 所以尽量别这么直接. 除非你们关系非常好.

#28 楼 @seveniruby 这么复杂。。我只是想帮他尽快解决问题而已,好吧,下次记住了,谢谢提醒~~

#29 楼 @rabbit 好吧, 是我搞错了, 把你们两个角色给搞颠倒了. sorry

#23 楼 @shery_zhang2012 从错误信息上看, http://localhost:4723/wd/hub 访问出错, 你可以自己手工用浏览器打开试试.看看有没有结果.

File "appium-0.11.3\appium-0.11.3\sample-code\examples\python\android_contacts
.py", line 17, in
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

#29 楼 @rabbit 你这么热心, 赞, 我们鼓励这种做法

#32 楼 @seveniruby 呵呵,只是帮助别人的同时,自己也进步。。这个问题我怀疑是他用的模拟器的原因,由于太慢,连接访问没有返回,现在在确认。

#33 楼 @rabbit 赞. 他最后出错在了访问 4723 端口上, 我觉得还是手工访问下看看上面情况, 估计是启动也有问题.

appium 依赖的条件, 很多人都没装齐备, 我后续考虑写个协助分析的脚本给他们. 发现环境有问题, 直接给出提示.

Shery #35 · 2013年11月13日 Author

@ #25 楼 lihuazhang @#32 楼 seveniruby @#33 楼 rabbit 感谢大家的热心帮忙,尤其感谢 #33 楼 rabbit ,利用休息时间帮我弄环境,现在总结一下我的心得:
1、下载 AppiumForWindows 版本,也要在线安装 WedDriver,即执行:npm install wd。
2、sample 所在的文件夹的名字不要有空格,否则会显示找不到 APK
3、windows 上的 Android 模拟器运行起来太慢了,导致会长时间接收不到指令,server 端会死掉

#35 楼 @shery_zhang2012 建议可以新开一个帖子出来总结哟~~

Shery #37 · 2013年11月19日 Author

rabbit 33 楼 , seveniruby 34 楼 , 我的环境遇到了这个问题:是什么原因呢?各位大神遇到没呢
1、直接用 F5 运行:
Traceback (most recent call last):
File "D:\appium-0.11.3\sample-code\examples\python\android_contacts.py", line 13, in
desired_caps['app'] = PATH('../../../sample-code/apps/ContactManager/ContactManager.apk')
File "D:\appium-0.11.3\sample-code\examples\python\android_contacts.py", line 6, in
os.path.join(os.path.dirname(file), p)
NameError: global name 'file' is not defined

2、用命令行运行:
Traceback (most recent call last):
File "android_contacts.py", line 17, in
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
File "D:\Python27\lib\site-packages\selenium-2.37.2-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 71, in init
self.start_session(desired_capabilities, browser_profile)
File "D:\Python27\lib\site-packages\selenium-2.37.2-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 113, in start_session
'desiredCapabilities': desired_capabilities,
File "D:\Python27\lib\site-packages\selenium-2.37.2-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 164, in execute
self.error_handler.check_response(response)
File "D:\Python27\lib\site-packages\selenium-2.37.2-py2.7.egg\selenium\webdriver\remote\errorhandler.py", line 136, in check_response
raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message: '<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtdn">\\n<!-- FileNam
e: index.html\n Language: [en]\n-->\n<!--Head-->\n\n \n\n<!--\ntd {\n\t\xe3\x80\x80color:#666666;font-size:12px; f
ont-family:Verdana, Arial, Helvetica, sans-serif; \n}\nbody {\n\tbackground-color: #999999;\n}\n.STYLE1 {color: #666666}\n.style8 {\tFONT-WEIGHT: bold\n}\n.style9 {color: #555555}\n\n-->\n\n\n
\n \xe4\xb8\x9c\xe8\xbd\xafInternet\xe8\xae\xbf\xe9\x97\xae\xe7\xae\xa1\xe7\x90\x86\xe9\xa1\xb5\n \n \n\n<!--/Head-->\n
<!--Body-->\n\n

\n \n \n \n
\n<!--Logo-->\n\n \
n \n \n
\n \n
\n<!--/Logo-->\n<!--Contents-->\n<!-- FileName: a
uthenticationrequired.html\n Language: [en]\n-->\n<!--Title-->\n\n \n \n \n
leData\'>\n authen required!\n
\n<!--/Title-->\n\n<!--Content-->\n\n \n \n \n
\n please supply username and pas
sword!\n
\n<!--/Content-->\n\n<!--Info-->\n\n \n \n \n
\n URL: http://127.0.0.1:4723/wd/hub/session
\n
User name:
\n
\n<!--/Info-->\n<!--/Contents-->\n<!--Policy-->\n\n \n \n \n \n \n \n \n\n\n \n\n \n
\n
\n \xe4\xb
8\x9c\xe8\xbd\xafInternet\xe8\xae\xbf\xe9\x97\xae\xe7\xae\xa1\xe7\x90\x86\xe5\x8a\x9e\xe6\xb3\x95\n
\n1. \xe5\xbc\x80\xe6\x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7\xa6\x81\xe6\xad\xa2\xe9\x80\x9a\xe8\xbf\x87\xe4\x
bb\xa3\xe7\x90\x86\xe8\xae\xbf\xe9\x97\xae\xe5\x85\xac\xe5\x8f\xb8\xe5\x86\x85\xe7\xbd\x91\xe8\xb5\x84\xe6\xba\x90\xef\xbc\x9b \n\n
\n3. \xe4\xb8\xb
a\xe6\xbb\xa1\xe8\xb6\xb3\xe5\x91\x98\xe5\xb7\xa5\xe7\x89\xb9\xe6\xae\x8a\xe9\x9c\x80\xe6\xb1\x82\xef\xbc\x8c\xe5\x85\xac\xe5\x8f\xb8\xe6\x8f\x90\xe4\xbe\x9b\xe7\xbd\x91\xe7\xab\x99\xe5\xbc\x80\xe9\x8
0\x9a\xe7\x9a\x84\xe6\xb5\x81\xe7\xa8\x8b\xef\xbc\x8c\xe5\x85\xb7\xe4\xbd\x93\xe8\xaf\xb7\xe5\x8f\x82\xe8\xa7\x81web.neusoft.com->\xe6\x9c\x8d\xe5\x8a\xa1\xe5\xb9\xb3\xe5\x8f\xb0->IT\xe6\x9c\x8d\xe5\x
8a\xa1\xe7\xae\xa1\xe7\x90\x86 \xe5\x8f\x91\xe5\xb8\x83\xe7\x9a\x84\xe6\xb5\x81\xe7\xa8\x8b\xe5\x92\x8c\xe8\xa1\xa8\xe6\xa0\xbc\xe3\x80\x82\n
\n<!--/Policy-->\n<!--Fo
ot-->\n\n \n \n \n \n \n \n \n \n \n
\n \xe4\xbf\xa1\xe6\x81\xaf\xe8\xa7\x84\xe5\x88\x92\xe4\xb8\x8e\xe7\xae\xa1\xe7\x90\x86\xe9\x83\xa8\xef\xbc\x8c\xe6\xb2
\x88\xe9\x98\xb3\xe5\x9b\xad\xe5\x8c\xbaA2\xe6\xa5\xbc231\xe6\x88\xbf\xe9\x97\xb4 \xe9\x82\xae\xe4\xbb\xb6\xef\xbc\x9aipm@neusoft.com\n
\n
\xe7\x94\xb5\xe8\xaf\x9d\xef\xbc\x9a+86-24-83665512\xe3\x80\x80\xe3\x80\x80\xe4\xbc\xa0\xe7\x9c\x9f\xef\xbc\x9a+86-24-83669548 \n
lor="#0088cc" style="font-size:12px">\n \n \n\t\t\t\n\n
\n<!--/Foot-->\n
\n\n<!--/Body-->\n\n'

我觉得你对整个体系还不太了解

启动 appium 后, 首先要用浏览器打开http://127.0.0.1:4723/wd/hub看看有没有启动成功.
然后再运行 python 脚本, 需要通过 python 的工具来安装他依赖的 webdriver 库.

分析问题的时候,你需要关注如下几个内容

  1. appium 的窗口有没有显示有客户端连接的 log 数据. 里面会有报错.
  2. python 运行自己的 log, 这个你已经提供出来了

另外不要在有空格的路径下, 貌似 java 和 python 对这种路径支持不太好

Shery #36 · 2013年11月21日 Author

#38 楼 seveniruby 这个问题解决了,是因为我用了代理上网,把代理关掉就 OK 了

c:\users\wangli\.node-gyp\0.10.21\deps\uv\include\uv-private/uv-win.h(32): fatal error C1083: 无法打开包括文件:“winsock2.h”: No such file or directory [C:\Users\wangli\node_modules\appium\node_modules\ws\build\binding.sln]
项目 : warning PRJ0018: 未找到下列环境变量: [C:\Users\wangli\node_modules\appium\node_modules\ws\build\binding.sln]
c:\users\wangli\.node-gyp\0.10.21\deps\uv\include\uv-private/uv-win.h(32): fatal error C1083: 无法打开包括文件:“winsock2.h”: No such file or directory [C:\Users\wangli\node_modules\appium\node_modules\ws\build\binding.sln]
项目 : warning PRJ0018: 未找到下列环境变量: [C:\Users\wangli\node_modules\appium\node_modules\ws\build\binding.sln]

用 npm install appium 安装时出现这个问题,它说的那个路径下有那个 binding.sln 文件。求解~~

#40 楼 @mingway_hu http://stackoverflow.com/questions/17496189/error-in-installing-node-js-module-using-npm
1
down vote
accepted
You need to add VCBuild.exe to your path. Check out this answer on how to do it: Testacular install failes, no vcbuild.exe

#41 楼 @lihuazhang I will try it. Thanks for your help.

#38 楼 @seveniruby 请问下启动成功的标志是什么?"That URL did not map to a valid JSONWP resource"这个有启动成功吗?另外:
warn:Android did not shut down fast enough, calling it gone
error:ADB quit before it successfully launched
info: We're in android's exit callback but adb is gone already
这个是怎么回事?谢谢

#43 楼 @leopold 成功的话是没有报错的, 他的意思貌似 adb 提前退出了, 这个需要看你的执行上下文环境才能判断了

Shery #45 · 2013年11月26日 Author

@seveniruby @monkey
在元素定位时,通过 id 进行定位,在 id 的名称中支持下划线吗?如果支持为什么通过 monitor 获得的 id 不能找到呢?

都这么多问题了,最近忙着换工作,也没来看,帖子太长了,看起来费劲,要不整理下吧!

47楼 已删除
48楼 已删除

根据这个文档 http://testerhome.com/topics/182 。 windows 下运行 java,模拟器没有跑起来! 怎么解决呀

@meimeiyuyun 他说你 app 的地址不对╮(╯_╰)╭。 加个头像吧~

51楼 已删除

#12 楼 @seveniruby 指导下我吧,碰到一个 appium 问题

#49 楼 @wusen 重新开个帖子, 把你的问题和代码都贴下看看

#17 楼 @rabbit 我界面安装运行成功、交流一下 界面中的那个 i 功能 用成功了

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