appium version:1.20.1
微信版本:安卓 8.0.1
微信的 weiview 版本:77.0.3865.120
导入的 chromedriver 版本:77.0.3865.40
# 导入
from appium import webdriver
# 初始化appium
caps["deviceName"] = "android"
caps["appPackage"] = "com.tencent.mm"
caps["appActivity"] = "com.tencent.mm.ui.LauncherUI"
caps["autoGrantPermissions"] = "true"
caps["chromedriverExecutable"] = "/Users/kid/drivers/webdrivers/chrome/77.0.3865.40/chromedriver"
caps["skipDeviceInitialization"] = "true"
caps["noReset"] = "true"
caps["udid"] = "DUPNW17920003090"
caps["chromeOptions"] = {"androidProcess": "com.tencent.mm:appbrand0"}
caps["BrowserName"] = ""
caps['recreateChromeDriverSessions'] = True
caps['newCommandTimeout'] = 100
caps['automationName'] = "uiautomator2"
self.driver = webdriver.Remote("http://localhost:4723/wd/hub", caps)
self.driver.implicitly_wait(10)
# 打开小程序,省略
self.driver.switch_to.context("WEBVIEW_com.tencent.mm:appbrand0")
hans = self.driver.window_handles
self.driver.switch_to.window(hans[-1])
# switch context、window后,是可以打印小程序页面代码的
print(self.driver.page_source)
# 查看小程序元素
self.driver.find_elements("class name", "list-name")
这是appium的日志
[W3C (3489199f)] Driver proxy active, passing request on via HTTP proxy
[debug] [WD Proxy] Matched '/wd/hub/session/3489199f-0cb2-472a-98d1-323142ecad99/elements' to command name 'findElements'
[debug] [WD Proxy] Proxying [POST /wd/hub/session/3489199f-0cb2-472a-98d1-323142ecad99/elements] to [POST http://127.0.0.1:8013/wd/hub/session/15f2559115fa272bd39691e131dfbcba/elements] with body: {"using":"class name","value":"list-name"}
[WD Proxy] Got response with status 400: {"value":{"error":"invalid argument","message":"invalid argument: invalid locator\n (Session info: chrome=77.0.3865.120)","stacktrace":"0 chromedriver 0x000000010886af09 chromedriver + 3694345\n1 chromedriver 0x00000001087f7fd3 chromedriver + 3223507\n2 chromedriver 0x000000010859758f chromedriver + 730511\n3 chromedriver 0x0000000108507c74 chromedriver + 142452\n4 chromedriver 0x00000001085314d1 chromedriver + 312529\n5 chromedriver 0x00000001085240bd chromedriver + 258237\n6 chromedriver 0x000000010852f711 chromedriver + 304913\n7 chromedriver 0x0000000108524383 chromedriver + 258947\n8 chromedriver 0x00000001084ff23d chromedriver + 107069\n9 chromedriver 0x00000001085001d5 chromedriver + 111061\n10 chromedriver 0x000000010882607f chr...
[debug] [W3C] Matched W3C error code 'invalid argument' to InvalidArgumentError
[HTTP] <-- POST /wd/hub/session/3489199f-0cb2-472a-98d1-323142ecad99/elements 400 26 ms - 1785
求解!!!!