from appium import webdriver
import time,traceback
desired_caps = {
}
# Test platform , Can't write wrong
desired_caps['platformName'] = 'Android'
# Platform version , Can't write wrong
desired_caps['platformVersion'] = '8.1.0'
# Equipment name ,android Fill in any value on the
desired_caps['deviceName'] = 'test'
# apk File pathname , If the device does not already have this app , Will install .
#desired_caps['app'] = r'd:\apk\wv.apk'
# app package name , Be sure to have , The developer gave app Take the name , Can uniquely identify this app.
desired_caps['appPackage'] = 'com.ibox.calculators'
# app start-up Activity, It is also a required parameter . An android app Activity As the corresponding
# A user interface
desired_caps['appActivity'] = '.SplashActivity'
# If we automate , There are Chinese characters in the information to be input , I need this parameter , Otherwise, we can not
# Adding this parameter will add a new unicode typewriting
#desired_caps['unicodeKeyboard'] = True
# After the test , The input method should be restored to the original , For example, it was Sogou input method
#desired_caps['resetKeyboard'] = True
# This noReset Parameters , It's very important !!
# To ensure the app The data will not be cleared before the test , By default, the data will be cleared
desired_caps['noReset'] = True
# Our test program is connected to appium server after ,appium server Have been waiting for client The order of .
# If more than a certain time , No order , such as debug When , It will assume that the client has exited . Will disconnect
# This parameter specifies how long ,appium
#erver It can be considered that the connection has been disconnected
desired_caps['newCommandTimeout'] = 6000
# start-up Remote RPC, take capability Parameters of the incoming ,
# Create a
#webdriver object , and Selenium
# similar .
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
# Start automation
#3
driver.find_element_by_id('com.ibox.calculators:id/digit3').click()
#+
driver.find_element_by_id('com.ibox.calculators:id/plus').click()
#9widget
driver.find_element_by_id('com.ibox.calculators:id/digit9').click()
#=
driver.find_element_by_id('com.ibox.calculators:id/equal').click()
#*
driver.find_element_by_id('com.ibox.calculators:id/mul').click()
#5
driver.find_element_by_id('com.ibox.calculators:id/digit5').click()
#=
driver.find_element_by_id('com.ibox.calculators:id/equal').click()
# To get the results
#ele=driver.find_element_by_id('cv')
#res=ele.find_elements_by_class_name('android.widget.TextView')[1]
res=driver.find_element_by_xpath('/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.LinearLayout/android.widget.RelativeLayout[1]/android.widget.RelativeLayout[1]/android.widget.LinearLayout[1]/android.widget.RelativeLayout/android.widget.TextView[2]')
# Check the calculation results
if res.text=='60':
print('pass')
else:
print('fail')
print(res.text)
Un..Régler la goupille avant d
Catalog Graphical user interf