appium自动化,UnknownError: An unknown server-side error occurred while processing the command

代码如下:

import time
from appium.webdriver import Remote
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
caps = {
    "platformName":"Android",
    "chromedriverExecutableDir":r"/Users/shao/Downloads/chromedriver",
    "udid":"emulator-5554",
    "appPackage":"com.lemon.lemonban",
    "appActivity":".activity.MainActivity",
}

driver = Remote(desired_capabilities=caps,
                command_executor='http://127.0.0.1:4723/wd/hub')
driver.implicitly_wait(10)

#点击师资团队进入web页面
driver.find_element('xpath',"//*[@text='师资团队']").click()
#打印所有的上下文
print(driver.contexts)
#上下文切换
driver.switch_to.context('WEBVIEW_com.lemon.lemonban')
#或者是
# driver.switch_to.context(driver.contexts[-1])
#点击菜单
driver.find_element('xpath',"//span[text()='更多']").click()

已经检查了包名都拼写无误,还是报错,
在这里插入图片描述并且appium报错No Chromedriver found that can automate Chrome ‘66.0.3359’. Seexxx

经过以下2步解决问题

(1)将代码中的

caps = {"chromedriverExecutable": r"path"
}

替换为

caps = {"appium:chromedriverExecutable"r"path"}

(2)手机上的浏览器版本为66.0.3359.158,可能是与chromedriver版本不匹配的缘故,重新下载对应版本的谷歌驱动,在代码中指定Chromedriver路径
(Chromedriver下载地址:https://npmmirror.com/)
appium自动化,UnknownError: An unknown server-side error occurred while processing the command_第1张图片appium自动化,UnknownError: An unknown server-side error occurred while processing the command_第2张图片
经过以上2步,完美解决!

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