Appium入門指令碼

2022-08-21 07:21:10 字數 1611 閱讀 3295

沒有用框架的**實現登入功能:

import time

from selenium import webdriver

# 建立字典

desired_caps = {}

desired_caps['platformname'] = 'android'

desired_caps['platformversion'] = '5.1'

desired_caps['devicename'] = 'm2 note'

# 方便輸入中文

desired_caps['unicodekeyboard'] = 'true'

desired_caps['resetkeyboard'] = 'true'

# 每次測試清空快取

# 通過xpath定位「去登入」按鈕並點選

driver.find_element_by_xpath('/hierarchy/android.widget.framelayout/android.widget.linearlayout/android.widget.framelayout/android.widget.relativelayout/android.widget.textview[2]').click()

# 輸入使用者名稱、密碼,點選登入按鈕

driver.find_element_by_xpath('/android.widget.framelayout/android.widget.relativelayout/android.widget.linearlayout[1]/android.widget.linearlayout[1]/android.widget.edittext').send_keys('username')

driver.find_element_by_xpath('/android.widget.framelayout/android.widget.relativelayout/android.widget.linearlayout[1]/android.widget.linearlayout[2]/android.widget.edittext').send_keys('password')

driver.find_element_by_xpath('/android.widget.framelayout/android.widget.relativelayout/android.widget.linearlayout[2]/android.widget.button').click()

# 判斷是否成功

try:

if driver.find_element_by_xpath("test/test").is_displayed():

print('pass')

except exception as e:

print(e)

print("fail")

time.sleep(3)

# 資源釋放

driver.quit()

appium新手入門

web應用 指可以使用移動瀏覽器 如ios上的safari和android上的chrome 訪問的應用 混合應用 指用原生 封裝網頁檢視,原生 和web內容互動的應用 coding utf 8 設定編碼格式 desired caps driver webdriver.remote desired c...

Appium入門(8) 控制項定位

如果目標裝置的api level低於18則uiautomatorviewer不能獲得對應的resource id,只有等於大於18的時候才能使用。開啟uiautomatorviewer.bat後同步裝置螢幕 id定位 driver.findelement by.id name定位 driver.fi...

appium新手入門之appium desktop

什麼是 appium desktop?專案位址 專案描述 appium server and inspector in desktop guis for mac,windows,and linux。appium 移動測試中有個很重新的元件?appium server,它主要用來監聽我們的移動裝置 真...