当前位置 : 主页 > 网络安全 > 测试自动化 >

Appium 计算器自动化实例

来源:互联网 收集:自由互联 发布时间:2021-06-19
#coding=utf-8 import os import time import unittest from appium import webdriver from lib2to3.pgen2.driver import Driver from lib2to3.tests.support import driver PATH=lambda p:os.path.abspath(os.path.join(os.path.dirname(__file__),p)) desir

#coding=utf-8
import os
import time
import unittest
from appium import webdriver
from lib2to3.pgen2.driver import Driver
from lib2to3.tests.support import driver
PATH=lambda p:os.path.abspath(os.path.join(os.path.dirname(__file__),p))

desired_caps = {}
desired_caps[‘platformName‘] = ‘Android‘
desired_caps[‘platformVersion‘] = ‘4.4.2‘
desired_caps[‘deviceName‘] = ‘HUAWEI C199‘

#desired_caps[‘app‘] = PATH(‘D:\\Appium\\StarZone_V2.0.0.apk‘) 
desired_caps[‘appPackage‘] = ‘com.android.calculator2‘
desired_caps[‘appActivity‘] = ‘.Calculator‘

driver = webdriver.Remote(‘http://localhost:4723/wd/hub‘, desired_caps)

#time.sleep(5)
driver.find_element_by_id("com.android.calculator2:id/clear").click()
driver.find_element_by_name("1").click()
driver.find_element_by_name("5").click()

driver.find_element_by_id("com.android.calculator2:id/plus").click()
driver.find_element_by_name("6").click()

driver.find_element_by_id("com.android.calculator2:id/equal").click()driver.quit()

网友评论