當前位置:
首頁 >
Appium+python实现App自动化登录
發布時間:2024/1/8
41
豆豆
生活随笔
收集整理的這篇文章主要介紹了
Appium+python实现App自动化登录
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Appium+python實現App自動化登錄
以下是個人用Appium + python寫的第一個App自動化案例,僅做單頁面,比較簡單,后續將涉及到主功能模塊化,需使用到功能時調用即可。
2.獲取Appium client端口值
driver = webdriver.Remote("http://localhost:4723/wd/hub", desired_caps)3.根據UIautomater定位元素
time.sleep(5) driver.find_element_by_name('我的').click() time.sleep(5) driver.find_element_by_name('登錄/注冊').click() time.sleep(5) driver.find_element_by_name('手機號').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' # 設備系統 desired_caps['platformVersion'] = '5.1.1' # 設備系統版本 desired_caps['deviceName'] = 'REDmi 3' # 設備名稱 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('登錄/注冊').click() time.sleep(5) driver.find_element_by_name('手機號').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()總結
以上是生活随笔為你收集整理的Appium+python实现App自动化登录的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 华为中兴为何对未来信心十足?
- 下一篇: python绘图设置正交坐标等距_pyt