1. Approximate process
+ 程序(Python):打开 QQ 音乐,点击一系列接收按键,进入搜索音乐界面,输入『Paradise』,播放第一首音乐。
2. The Python script is as follows
From appium import Webdriverimport timedesired_caps = {}desired_caps[' platformname '] = ' Android ' # adb shell Getprop Ro.bu Ild.version.release get version number desired_caps[' platformversion '] = ' 6.0 ' desired_caps[' devicename '] = ' Android Emulator ' Desir ed_caps[' apppackage ' = ' com.tencent.qqmusic ' # adb shell Dumpsys Activity Activities | grep "Realactivity" obtains appactivitydesired_caps[' appactivity '] = '. Activity. Appstarteractivity ' Driver = webdriver. Remote (' Http://localhost:4723/wd/hub ', Desired_caps) # A series of Click # Page1 sddriver.find_element_by_id (' Com.tencent.qqmusic:id/y3 '). Click () time.sleep (1) # Page2 telephone Com.android.packageinstaller:id/permission_allow_ buttondriver.find_element_by_id (' Com.android.packageinstaller:id/permission_allow_button '). Click () # Driver.findelementbyxpath ("//android.widget.button[@text = ' Always Allow ']"). Click (); Time.sleep (1) # Page3driver.find_ element_by_id (' Com.android.packageinstaller:id/permission_allow_button '). Click () time.sleep (1) # Page4 Com.tencent.qqmusic:id/v3 Skip Driver.find_element_by_id (' Com.tencent.qqmusic:id/v3 '). Click () time.sleep (1) # Page5 Cancel login driver.find_element_by_id (' Com.tencent.qqmusic:id/lh '). Click () time.sleep (1) # PAGE6 Click Shrink driver.find_element_by_id (' Com.tencent.qqmusic:id/ T3 '). Click () time.sleep (1) # Page7 driver.find_element_by_id (' com.tencent.qqmusic:id/a7j '). Click () Search_box = driver.find_element_by_id (' com.tencent.qqmusic:id/a7j ') Search_box.click () Search_box.send_keys (' Paradise ') # Enter the name of the retrieved song, does not support Chinese (like? ) Time.sleep (2) # com.tencent.qqmusic:id/cb3driver.find_element_by_id (' com.tencent.qqmusic:id/cb3 '). Click () Time.sleep (1) # com.tencent.qqmusic:id/a55driver.find_element_by_id (' Com.tencent.qqmusic:id/a55 '). Click () Time.sleep (1)
3. Program running Video (recording screen)
- Run mobile phone recorder, click to watch
Appium + Python Test A simple script for QQ Music app