代码改变世界

后台自动启动appium

2015-06-24 19:07  xiaoluosun  阅读(1102)  评论(0编辑  收藏  举报

 

首先说明,本人用的exe方式安装的appium。

新建一个.vbs文件,写入以下脚本,记得把D盘换成你自己的盘符。

1.后面taskkill好像没有实际作用。。加就加了吧。

Set ws = CreateObject("Wscript.Shell")
ws.run "D:\\Appium\\node_modules\\.bin\\appium.cmd && cmd /c start taskkill /im cmd.exe /f",vbhide

 

2.appium.cmd文件也可以换成同目录下appium文件。

Set ws = CreateObject("Wscript.Shell")
ws.run "D:\\Appium\\node_modules\\.bin\\appium && cmd /c start taskkill /im cmd.exe /f",vbhide

 

3.也可以用appium自带的node.exe运行main.js文件启动,后面可以加上一些初始属性。

Set ws = CreateObject("Wscript.Shell")
ws.run "D:\Appium\node.exe D:\Appium\node_modules\appium\lib\server\main.js --address 127.0.0.1 --port 4723 --platform-name Android --platform-version 18 --automation-name Appium --log-no-color",vbhide

 

 

当然你启动前最好检查下端口有没有被占用,如下代码

1 def kill_process(self):
2     u'''杀死占用5037端口的进程\n
3     '''          
4     try: 
5         pid = os.popen("netstat -ano | findstr 5037 | findstr  LISTENING").read().split()[-1]
6         os.system("taskkill /F /PID %s" %pid)
7     except IndexError as e:
8         print '端口没有被占用'