Launch Simulator, launch Appium Android AVD launch simulator admin Select a version start install appium-client direct pip install appium-python-client install simple script: Calculator parameters:platformname = Android #Android or iOS platformversion = version number of the 4.2 #android devicename = Android Emulator # emulator or device ID apppackage = com. Hunbohui.yingbasha #apk package name appactivity =. Component.menu.HomeActivity # boot name Webdriver. Remote ('http://localhost:4723/wd/hub', capabilities) The first parameter is fixed write OK, if using the remote machine to do the test,localhosts to the corresponding machine IP can be how to get Apppackage and appacitvity:1. Get Apppackage This is actually the name of the installation packageunder Android folder tools find Uiautomatorviewer and open, in the case of a linked phone, click:
this will get the current screenin the lower right detail you can find the package Com.android.calculator2, which is the name2. Get appacitvityCMD input: adb shell Dumpsys activity activities find this, use/split, front is package, behind isappacitvityHow to obtain the device number DeviceNamecmd under run ADB devicesThis is the device number .
# encoding=utf-8from Appium Import Webdriver desired_caps = {}desired_caps[' platformname '] = ' Android ' desired_caps[' Platformversion '] = ' 4.4.2 ' desired_caps[' devicename '] = ' Android Emulator ' desired_caps[' apppackage '] = ' Com.android.calculator2 ' desired_caps[' appactivity '] = '. Calculator ' Driver = webdriver. Remote (' Http://localhost:4723/wd/hub ', desired_caps) driver.find_element_by_name ("1"). Click () driver.find_element _by_name ("5"). Click () driver.find_element_by_name ("9"). Click () driver.find_element_by_name ("Delete"). Click () Driver.find_element_by_name ("9"). Click () driver.find_element_by_name ("5"). Click () driver.find_element_by_name ("+ "). Click () driver.find_element_by_name (" 6 "). Click () driver.find_element_by_name (" = "). Click () driver.quit ()
Appium Basic--one Demo