Appium+python实现App自动化登录
生活随笔
收集整理的這篇文章主要介紹了
Appium+python实现App自动化登录
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
Appium+python實(shí)現(xiàn)App自動(dòng)化登錄
以下是個(gè)人用Appium + python寫的第一個(gè)App自動(dòng)化案例,僅做單頁(yè)面,比較簡(jiǎn)單,后續(xù)將涉及到主功能模塊化,需使用到功能時(shí)調(diào)用即可。
2.獲取Appium client端口值
driver = webdriver.Remote("http://localhost:4723/wd/hub", desired_caps)3.根據(jù)UIautomater定位元素
time.sleep(5) driver.find_element_by_name('我的').click() time.sleep(5) driver.find_element_by_name('登錄/注冊(cè)').click() time.sleep(5) driver.find_element_by_name('手機(jī)號(hào)').send_keys('13112341237') time.sleep(3) driver.find_element_by_id('pwd_edit').send_keys('ss123456') time.sleep(3)driver.find_element_by_name('登錄').click() time.sleep(5)4.原始代碼
# -*- coding:utf-8 -*- import os, time, unittest from selenium import webdriverdesired_caps = {} desired_caps['platformName'] = 'Android' # 設(shè)備系統(tǒng) desired_caps['platformVersion'] = '5.1.1' # 設(shè)備系統(tǒng)版本 desired_caps['deviceName'] = 'REDmi 3' # 設(shè)備名稱 desired_caps['appPackage'] = 'com.formax.life' desired_caps['appActivity'] = 'formax.life.main.BootProxyActivity'driver = webdriver.Remote("http://localhost:4723/wd/hub", desired_caps) time.sleep(5) driver.find_element_by_name('我的').click() time.sleep(5) driver.find_element_by_name('登錄/注冊(cè)').click() time.sleep(5) driver.find_element_by_name('手機(jī)號(hào)').send_keys('13112341237') time.sleep(3) driver.find_element_by_id('pwd_edit').send_keys('ss123456') time.sleep(3)driver.find_element_by_name('登錄').click() time.sleep(5)driver.quit()總結(jié)
以上是生活随笔為你收集整理的Appium+python实现App自动化登录的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 华为中兴为何对未来信心十足?
- 下一篇: 姣婆遇着姿粉客~