appium报错:An unknown server-side error occurred while processing the command.

appium运行过程中报错:

An unknown server-side error occurred while processing the command. Original error: Could not proxy command to remote server. Original error: Error: read ECONNRESET

出错代码如下,查了好多方法都无法解决,只好直接去看源码

#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()

 

源码显示如下:

appium报错:An unknown server-side error occurred while processing the command._第1张图片

因此,将出错代码的

'automationName':'uiautomator2',

 改为如下即可

'ANDROID_UIAUTOMATOR':'uiautomator2',

 

 

你可能感兴趣的:(自动化测试,appium)