An error is reported during appium running:
The error code is as follows. I checked many methods and couldn't solve it, so I had to go directly to the source code
#coding:utf-8
from appium import webdriver
import time
desired_caps = {
'platformName':'Android',
'platformVersion':'7.1',
'deviceName':'c353ce90',
'fastReset': 'false',
'fullReset': 'false',
'noReset':'true',
'nativeWebScreenshot': 'true',
'androidScreenshotPath':'target/screenshots',
'automationName':'uiautomator2',
'appPackage':'com.tencent.mm',
'appActivity':'com.tencent.mm.ui.LauncherUI',
'chromeOptions':{'androidProcess':'com.tencent.mm:appbrand1'}
}
driver=webdriver.Remote('http://127.0.0.1:4723/wd/hub',desired_caps)
print(driver.current_activity)
time.sleep(5)
print("点击发现")
driver.find_element_by_xpath("//*[@text='发现']").click()
# 获取屏幕的size
size = driver.get_window_size()
# 获取屏幕宽度 width
width = size['width']
print(width)
# 获取屏幕高度 height
height = size['height']
# 执行滑屏操作,向上(上拉)滑动
x1 = width*0.5
y1 = height*0.9
y2 = height*0.25
time.sleep(3)
print("滑动前")
driver.swipe(x1,y1,x1,y2)
print("滑动后")
time.sleep(3)
print("点击小程序")
driver.find_element_by_xpath("//*[@text='小程序']").click()
time.sleep(10)
print(driver.page_source)
driver.find_element_by_xpath("//*[@text='猜歌王']").click()
The source code is shown as follows:
Therefore, the error code
'automationName':'uiautomator2',
Can be changed as follows
'ANDROID_UIAUTOMATOR':'uiautomator2',