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()

可以看到自動點擊了計算器

 

 

 

 

 

 

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