appium入门指南(一)appium环境安装

一、工作原理

appium client -> appium Server-> Android 模拟器或  Android 手机

二、安装

1、下载并安装Android Studio并配置环境变量(jdk变量配置好,node安装好)

新建安卓虚拟机

2、安装 appium Server或者appium destop

  (1)安装 appium Server

地址:https://bitbucket.org/appium/appium.app/downloads/

安装后如下,箭头标示按钮为开关

打开 Windows 命令提示符,输入“appium-doctor”命令

如下为成功,若失败查看是否环境变量配置是否 正确

(2)安装 appium destop

 

  3、安装 python- - client

python3 pip3 install Appium-Python-Client
python2  pip install Appium-Python-Client

三、运行

1、启动 Android 模拟器

2、启动 Appium Server

3、编写脚本:

# -*- encoding: utf-8 -*-
'''
Created on 2018年11月23日

@author: Administrator
'''
from appium import webdriver
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '6.0'
desired_caps['deviceName'] = 'Android Emulator'
desired_caps['appPackage'] = 'com.android.calculator2'
desired_caps['appActivity'] = '.Calculator'
driver  =  webdriver.Remote('http://localhost:4723/wd/hub',desired_caps)
driver.find_element_by_name("1").click()
driver.find_element_by_name("5").click()
driver.find_element_by_name("9").click()
driver.find_element_by_name("delete").click()
driver.find_element_by_name("9").click()
driver.find_element_by_name("5").click()
driver.find_element_by_name("+").click()
driver.find_element_by_name("6").click()
driver.find_element_by_name("=").click()
driver.quit()

可以看到自动点击了计算器

 

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章