i’ve searched servral topics about this, but make any sense,when i switch to webview, the appium log shows there is no webview i can change,here is my code and capabilities:
[Appium] Appium v1.13.0 creating new AndroidUiautomator2Driver (v1.33.1) session
[Appium] Capabilities:
[Appium] platformName: Android
[Appium] deviceName: 36c02a5
[Appium] platformVersion: 9
[Appium] automationName: UiAutomator2
[Appium] appPackage: com.tencent.mm
[Appium] appActivity: .ui.LauncherUI
[Appium] ChromeOptions: {
[Appium] androidProcess: com.tencent.mm:appbrand0
[Appium] }
[Appium] noReset: true
[Appium] fullReset: false
code:
“”“点击小程序按钮”“”
minipro = “小程序”
el_minipro = self.driver.find_element_by_android_uiautomator(“new UiSelector().text("”+minipro+“")”)
print(“页面上定位到小程序元素吗?:%s” % el_minipro.is_displayed())
if el_minipro.is_displayed():
el_minipro.click()
“”“切换页面活动值小程序列表显示页面”“”
self.driver.wait_activity(“.plugin.appbrand.ui.AppBrandLauncherUI”, THINK_TIME)
sleep(THINK_TIME)
print(“页面的所有模式”, self.driver.contexts)
target_minipro = “咖啡外卖”
el_target = action().find_byUiautormator(“textContains”, target_minipro)
print(“页面上定位到target小程序元素吗?:%s” % el_target.is_displayed())
if el_target.is_displayed():
el_target.click()
“”“点击小程序进入页面,切换进入webview页面”“”
self.driver.switch_to.context(“WEBVIEW_com.tencent.mm:appbrand0”)
sleep(10)
print(“当前页面的模式为:%s” % self.driver.context)
menu = “新品咖啡”
el_menu = action().find_byUiautormator(“text”, menu)
print(“页面上定位到小程序menu元素吗?:%s” % el_menu.is_displayed())
if el_menu.is_displayed():
el_menu.click()
appium log:
[HTTP] → POST /wd/hub/session/22d1ec00-f881-4d21-aaf2-15893928ff14/element
[HTTP] {“using”:“-android uiautomator”,“value”:“new UiSelector().text("小程序")”}
[W3C (22d1ec00)] Calling AppiumDriver.findElement() with args: [“-android uiautomator”,“new UiSelector().text("小程序")”,“22d1ec00-f881-4d21-aaf2-15893928ff14”]
[BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[BaseDriver] Waiting up to 0 ms for condition
[WD Proxy] Matched ‘/element’ to command name ‘findElement’
[WD Proxy] Proxying [POST /element] to [POST http://localhost:8200/wd/hub/session/394e282f-5662-4e81-83ba-c09ef94f8d0c/element] with body: {“strategy”:“-android uiautomator”,“selector”:“new UiSelector().text("小程序")”,“context”:“”,“multiple”:false}
[WD Proxy] Got response with status 200: {“sessionId”:“394e282f-5662-4e81-83ba-c09ef94f8d0c”,“status”:0,“value”:{“ELEMENT”:“a41c39cb-d50b-4899-9e47-aba5cd6c33e9”}}
[W3C (22d1ec00)] Responding to client with driver.findElement() result: {“element-6066-11e4-a52e-4f735466cecf”:“a41c39cb-d50b-4899-9e47-aba5cd6c33e9”,“ELEMENT”:“a41c39cb-d50b-4899-9e47-aba5cd6c33e9”}
[HTTP] ← POST /wd/hub/session/22d1ec00-f881-4d21-aaf2-15893928ff14/element 200 120 ms - 137
[HTTP]
[HTTP] → GET /wd/hub/session/22d1ec00-f881-4d21-aaf2-15893928ff14/element/a41c39cb-d50b-4899-9e47-aba5cd6c33e9/displayed
[HTTP] {}
[W3C (22d1ec00)] Calling AppiumDriver.elementDisplayed() with args: [“a41c39cb-d50b-4899-9e47-aba5cd6c33e9”,“22d1ec00-f881-4d21-aaf2-15893928ff14”]
[WD Proxy] Matched ‘/element/a41c39cb-d50b-4899-9e47-aba5cd6c33e9/attribute/displayed’ to command name ‘getAttribute’
[WD Proxy] Proxying [GET /element/a41c39cb-d50b-4899-9e47-aba5cd6c33e9/attribute/displayed] to [GET http://localhost:8200/wd/hub/session/394e282f-5662-4e81-83ba-c09ef94f8d0c/element/a41c39cb-d50b-4899-9e47-aba5cd6c33e9/attribute/displayed] with body: {}
[WD Proxy] Got response with status 200: “{"sessionId":"394e282f-5662-4e81-83ba-c09ef94f8d0c","status":0,"value":"true"}”
[W3C (22d1ec00)] Responding to client with driver.elementDisplayed() result: true
[HTTP] ← GET /wd/hub/session/22d1ec00-f881-4d21-aaf2-15893928ff14/element/a41c39cb-d50b-4899-9e47-aba5cd6c33e9/displayed 200 77 ms - 14
[HTTP]
[HTTP] → GET /wd/hub/session/22d1ec00-f881-4d21-aaf2-15893928ff14/element/a41c39cb-d50b-4899-9e47-aba5cd6c33e9/displayed
[HTTP] {}
[W3C (22d1ec00)] Calling AppiumDriver.elementDisplayed() with args: [“a41c39cb-d50b-4899-9e47-aba5cd6c33e9”,“22d1ec00-f881-4d21-aaf2-15893928ff14”]
[WD Proxy] Matched ‘/element/a41c39cb-d50b-4899-9e47-aba5cd6c33e9/attribute/displayed’ to command name ‘getAttribute’
[WD Proxy] Proxying [GET /element/a41c39cb-d50b-4899-9e47-aba5cd6c33e9/attribute/displayed] to [GET http://localhost:8200/wd/hub/session/394e282f-5662-4e81-83ba-c09ef94f8d0c/element/a41c39cb-d50b-4899-9e47-aba5cd6c33e9/attribute/displayed] with body: {}
[WD Proxy] Got response with status 200: “{"sessionId":"394e282f-5662-4e81-83ba-c09ef94f8d0c","status":0,"value":"true"}”
[W3C (22d1ec00)] Responding to client with driver.elementDisplayed() result: true
[HTTP] ← GET /wd/hub/session/22d1ec00-f881-4d21-aaf2-15893928ff14/element/a41c39cb-d50b-4899-9e47-aba5cd6c33e9/displayed 200 116 ms - 14
[HTTP]
[HTTP] → POST /wd/hub/session/22d1ec00-f881-4d21-aaf2-15893928ff14/element/a41c39cb-d50b-4899-9e47-aba5cd6c33e9/click
[HTTP] {“id”:“a41c39cb-d50b-4899-9e47-aba5cd6c33e9”}
[W3C (22d1ec00)] Calling AppiumDriver.click() with args: [“a41c39cb-d50b-4899-9e47-aba5cd6c33e9”,“22d1ec00-f881-4d21-aaf2-15893928ff14”]
[WD Proxy] Matched ‘/element/a41c39cb-d50b-4899-9e47-aba5cd6c33e9/click’ to command name ‘click’
[WD Proxy] Proxying [POST /element/a41c39cb-d50b-4899-9e47-aba5cd6c33e9/click] to [POST http://localhost:8200/wd/hub/session/394e282f-5662-4e81-83ba-c09ef94f8d0c/element/a41c39cb-d50b-4899-9e47-aba5cd6c33e9/click] with body: {“element”:“a41c39cb-d50b-4899-9e47-aba5cd6c33e9”}
[WD Proxy] Got response with status 200: {“sessionId”:“394e282f-5662-4e81-83ba-c09ef94f8d0c”,“status”:0,“value”:true}
[W3C (22d1ec00)] Responding to client with driver.click() result: true
[HTTP] ← POST /wd/hub/session/22d1ec00-f881-4d21-aaf2-15893928ff14/element/a41c39cb-d50b-4899-9e47-aba5cd6c33e9/click 200 2509 ms - 14
[HTTP]
[HTTP] → GET /wd/hub/session/22d1ec00-f881-4d21-aaf2-15893928ff14/appium/device/current_activity
[HTTP] {}
[W3C (22d1ec00)] Calling AppiumDriver.getCurrentActivity() with args: [“22d1ec00-f881-4d21-aaf2-15893928ff14”]
[ADB] Getting focused package and activity
[ADB] Running ‘D:\adt-bundle-windows\sdk\platform-tools\adb.exe -P 5037 -s 36c02a5 shell dumpsys window windows’
[W3C (22d1ec00)] Responding to client with driver.getCurrentActivity() result: “.plugin.appbrand.ui.AppBrandLauncherUI”
[HTTP] ← GET /wd/hub/session/22d1ec00-f881-4d21-aaf2-15893928ff14/appium/device/current_activity 200 265 ms - 50
[HTTP]
[HTTP] → GET /wd/hub/session/22d1ec00-f881-4d21-aaf2-15893928ff14/contexts
[HTTP] {}
[W3C (22d1ec00)] Calling AppiumDriver.getContexts() with args: [“22d1ec00-f881-4d21-aaf2-15893928ff14”]
[AndroidDriver] Getting a list of available webviews
[ADB] Running ‘D:\adt-bundle-windows\sdk\platform-tools\adb.exe -P 5037 -s 36c02a5 shell cat /proc/net/unix’
[AndroidDriver] Found webviews:
[AndroidDriver] Available contexts: [“NATIVE_APP”]
[W3C (22d1ec00)] Responding to client with driver.getContexts() result: [“NATIVE_APP”]
[HTTP] ← GET /wd/hub/session/22d1ec00-f881-4d21-aaf2-15893928ff14/contexts 200 120 ms - 24
[HTTP]
[HTTP] → POST /wd/hub/session/22d1ec00-f881-4d21-aaf2-15893928ff14/element
[HTTP] {“using”:“-android uiautomator”,“value”:“new UiSelector(). textContains("咖啡外卖")”}
[W3C (22d1ec00)] Calling AppiumDriver.findElement() with args: [“-android uiautomator”,“new UiSelector(). textContains("咖啡外卖")”,“22d1ec00-f881-4d21-aaf2-15893928ff14”]
[BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[BaseDriver] Waiting up to 0 ms for condition
[WD Proxy] Matched ‘/element’ to command name ‘findElement’
[WD Proxy] Proxying [POST /element] to [POST http://localhost:8200/wd/hub/session/394e282f-5662-4e81-83ba-c09ef94f8d0c/element] with body: {“strategy”:“-android uiautomator”,“selector”:“new UiSelector(). textContains("咖啡外卖")”,“context”:“”,“multiple”:false}
[WD Proxy] Got response with status 200: {“sessionId”:“394e282f-5662-4e81-83ba-c09ef94f8d0c”,“status”:0,“value”:{“ELEMENT”:“e627d987-4273-4fca-92f9-dc49cedae90e”}}
[W3C (22d1ec00)] Responding to client with driver.findElement() result: {“element-6066-11e4-a52e-4f735466cecf”:“e627d987-4273-4fca-92f9-dc49cedae90e”,“ELEMENT”:“e627d987-4273-4fca-92f9-dc49cedae90e”}
[HTTP] ← POST /wd/hub/session/22d1ec00-f881-4d21-aaf2-15893928ff14/element 200 87 ms - 137
[HTTP]
[HTTP] → GET /wd/hub/session/22d1ec00-f881-4d21-aaf2-15893928ff14/element/e627d987-4273-4fca-92f9-dc49cedae90e/displayed
[HTTP] {}
[W3C (22d1ec00)] Calling AppiumDriver.elementDisplayed() with args: [“e627d987-4273-4fca-92f9-dc49cedae90e”,“22d1ec00-f881-4d21-aaf2-15893928ff14”]
[WD Proxy] Matched ‘/element/e627d987-4273-4fca-92f9-dc49cedae90e/attribute/displayed’ to command name ‘getAttribute’
[WD Proxy] Proxying [GET /element/e627d987-4273-4fca-92f9-dc49cedae90e/attribute/displayed] to [GET http://localhost:8200/wd/hub/session/394e282f-5662-4e81-83ba-c09ef94f8d0c/element/e627d987-4273-4fca-92f9-dc49cedae90e/attribute/displayed] with body: {}
[WD Proxy] Got response with status 200: “{"sessionId":"394e282f-5662-4e81-83ba-c09ef94f8d0c","status":0,"value":"true"}”
[W3C (22d1ec00)] Responding to client with driver.elementDisplayed() result: true
[HTTP] ← GET /wd/hub/session/22d1ec00-f881-4d21-aaf2-15893928ff14/element/e627d987-4273-4fca-92f9-dc49cedae90e/displayed 200 72 ms - 14
[HTTP]
[HTTP] → GET /wd/hub/session/22d1ec00-f881-4d21-aaf2-15893928ff14/element/e627d987-4273-4fca-92f9-dc49cedae90e/displayed
[HTTP] {}
[W3C (22d1ec00)] Calling AppiumDriver.elementDisplayed() with args: [“e627d987-4273-4fca-92f9-dc49cedae90e”,“22d1ec00-f881-4d21-aaf2-15893928ff14”]
[WD Proxy] Matched ‘/element/e627d987-4273-4fca-92f9-dc49cedae90e/attribute/displayed’ to command name ‘getAttribute’
[WD Proxy] Proxying [GET /element/e627d987-4273-4fca-92f9-dc49cedae90e/attribute/displayed] to [GET http://localhost:8200/wd/hub/session/394e282f-5662-4e81-83ba-c09ef94f8d0c/element/e627d987-4273-4fca-92f9-dc49cedae90e/attribute/displayed] with body: {}
[WD Proxy] Got response with status 200: “{"sessionId":"394e282f-5662-4e81-83ba-c09ef94f8d0c","status":0,"value":"true"}”
[W3C (22d1ec00)] Responding to client with driver.elementDisplayed() result: true
[HTTP] ← GET /wd/hub/session/22d1ec00-f881-4d21-aaf2-15893928ff14/element/e627d987-4273-4fca-92f9-dc49cedae90e/displayed 200 54 ms - 14
[HTTP]
[HTTP] → POST /wd/hub/session/22d1ec00-f881-4d21-aaf2-15893928ff14/element/e627d987-4273-4fca-92f9-dc49cedae90e/click
[HTTP] {“id”:“e627d987-4273-4fca-92f9-dc49cedae90e”}
[W3C (22d1ec00)] Calling AppiumDriver.click() with args: [“e627d987-4273-4fca-92f9-dc49cedae90e”,“22d1ec00-f881-4d21-aaf2-15893928ff14”]
[WD Proxy] Matched ‘/element/e627d987-4273-4fca-92f9-dc49cedae90e/click’ to command name ‘click’
[WD Proxy] Proxying [POST /element/e627d987-4273-4fca-92f9-dc49cedae90e/click] to [POST http://localhost:8200/wd/hub/session/394e282f-5662-4e81-83ba-c09ef94f8d0c/element/e627d987-4273-4fca-92f9-dc49cedae90e/click] with body: {“element”:“e627d987-4273-4fca-92f9-dc49cedae90e”}
[WD Proxy] Got response with status 200: {“sessionId”:“394e282f-5662-4e81-83ba-c09ef94f8d0c”,“status”:0,“value”:true}
[W3C (22d1ec00)] Responding to client with driver.click() result: true
[HTTP] ← POST /wd/hub/session/22d1ec00-f881-4d21-aaf2-15893928ff14/element/e627d987-4273-4fca-92f9-dc49cedae90e/click 200 2548 ms - 14
[HTTP]
[HTTP] → POST /wd/hub/session/22d1ec00-f881-4d21-aaf2-15893928ff14/context
[HTTP] {“name”:“WEBVIEW_com.tencent.mm:appbrand0”}
[W3C (22d1ec00)] Calling AppiumDriver.setContext() with args: [“WEBVIEW_com.tencent.mm:appbrand0”,“22d1ec00-f881-4d21-aaf2-15893928ff14”]
[AndroidDriver] Getting a list of available webviews
[ADB] Running ‘D:\adt-bundle-windows\sdk\platform-tools\adb.exe -P 5037 -s 36c02a5 shell cat /proc/net/unix’
[AndroidDriver] Found webviews:
[AndroidDriver] Available contexts: [“NATIVE_APP”]
[W3C (22d1ec00)] Encountered internal error running command: NoSuchContextError: No such context found.