APP自动化测试-11.webview技术原理

2023-11-09

APP自动化测试-11.webview技术原理



前言

根据日志,简单记录webview运行的机制


脚本:

from time import sleep

import pytest
from appium import webdriver
from appium.webdriver.common.appiumby import AppiumBy
from selenium.webdriver.common.by import By


class TestHybrid:

    def setup(self):
        desired_caps = {
            "platformName": "android",
            "appium:deviceName": "b1f37e8e",
            "appium:appPackage": "io.appium.android.apis",
            "appium:appActivity": ".ApiDemos",
            "chromedriverExecutableDir": "/Users/gaozeyu/tools/chromedriverdir",
            "chromedriverChromeMappingFile": "/Users/gaozeyu/PycharmProjects/test_appium/testcase/mapping.json"
        }

        self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

        # 设置隐式等待
        self.driver.implicitly_wait(10)

    def teardown(self):
        self.driver.quit()

    def test_hybrid(self):
        sleep(3)
        self.driver.find_element(AppiumBy.ACCESSIBILITY_ID, 'Views').click()
        webview = "WebView"
        self.driver.find_element(AppiumBy.ANDROID_UIAUTOMATOR, f'new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().text("{webview}").instance(0));').click()

        print(self.driver.contexts)
        # 切换上下文,由原生切换至webview
        self.driver.switch_to.context(self.driver.contexts[-1])
        self.driver.find_element(By.XPATH, '//*[@id="i_am_a_textbox"]').send_keys("this is a test message")

        # 窗口切换
        print(self.driver.window_handles)
        self.driver.find_element(By.XPATH, '//*[@id="i am a link"]').click()
        print(self.driver.window_handles)

        sleep(3)

        if __name__ == 'main':
            pytest.main()

一、获取webview

第一次调用webview脚本代码:

print(self.driver.contexts)

日志文件分析:

2022-08-11 09:03:28:560 [HTTP] --> GET /wd/hub/session/d2d0b17c-fb8b-4422-93e3-a65e327eefdb/contexts
2022-08-11 09:03:28:560 [HTTP] {}
2022-08-11 09:03:28:561 [W3C (d2d0b17c)] Calling AppiumDriver.getContexts() with args: ["d2d0b17c-fb8b-4422-93e3-a65e327eefdb"]
2022-08-11 09:03:28:561 [AndroidDriver] Getting a list of available webviews
2022-08-11 09:03:28:565 [ADB] Running '/Users/gaozeyu/Library/Android/sdk/platform-tools/adb -P 5037 -s b1f37e8e shell cat /proc/net/unix'
2022-08-11 09:03:28:630 [AndroidDriver] Parsed 1 active devtools socket: ["@webview_devtools_remote_12270"]
2022-08-11 09:03:28:631 [AndroidDriver] Collecting CDP data of 1 webview
2022-08-11 09:03:28:631 [AndroidDriver] Forwarding remote port webview_devtools_remote_12270 to a local port in range 10900..11000
2022-08-11 09:03:28:631 [AndroidDriver] You could use the 'webviewDevtoolsPort' capability to customize the starting port number
2022-08-11 09:03:28:636 [ADB] Running '/Users/test/Library/Android/sdk/platform-tools/adb -P 5037 -s b1f37e8e forward tcp:10900 localabstract:webview_devtools_remote_12270'
2022-08-11 09:03:28:672 [ADB] Removing forwarded port socket connection: 10900 
2022-08-11 09:03:28:673 [ADB] Running '/Users/test/Library/Android/sdk/platform-tools/adb -P 5037 -s b1f37e8e forward --remove tcp:10900'
2022-08-11 09:03:28:693 [AndroidDriver] CDP data collection completed
2022-08-11 09:03:28:693 [AndroidDriver] WEBVIEW_12270 mapped to pid 12270
2022-08-11 09:03:28:693 [AndroidDriver] Getting process name for webview 'WEBVIEW_12270'
2022-08-11 09:03:28:693 [ADB] Running '/Users/test/Library/Android/sdk/platform-tools/adb -P 5037 -s b1f37e8e shell ps -A'
2022-08-11 09:03:28:821 [AndroidDriver] Got process name: 'io.appium.android.apis'
2022-08-11 09:03:28:822 [AndroidDriver] Found 1 webview: ["WEBVIEW_io.appium.android.apis"]
2022-08-11 09:03:28:822 [AndroidDriver] Available contexts: ["NATIVE_APP","WEBVIEW_io.appium.android.apis"]
2022-08-11 09:03:28:823 [W3C (d2d0b17c)] Responding to client with driver.getContexts() result: ["NATIVE_APP","WEBVIEW_io.appium.android.apis"]
2022-08-11 09:03:28:823 [HTTP] <-- GET /wd/hub/session/d2d0b17c-fb8b-4422-93e3-a65e327eefdb/contexts 200 263 ms - 57

    1. appium server 接收到获取contexts的请求
[HTTP] --> GET /wd/hub/session/d2d0b17c-fb8b-4422-93e3-a65e327eefdb/contexts
    1. 调用AppiumDriver.getContexts()方法,获取contexts,此时获取到1个可用的webview的list
[W3C (d2d0b17c)] Calling AppiumDriver.getContexts() with args: ["d2d0b17c-fb8b-4422-93e3-a65e327eefdb"]
[AndroidDriver] Getting a list of available webviews
    1. adb命令查看手机端的监听
adb -P 5037 -s b1f37e8e shell cat /proc/net/unix'
    1. 获取webview所有的socket
adb shell cat /proc/net/unix | grep webview
    1. 根据获取的webview的socket,查询进程
# pid为进程号
adb shell ps | grep pid
    1. 获取进程名称和webview,返回给客户端
[AndroidDriver] Got process name: 'io.appium.android.apis'
[AndroidDriver] Found 1 webview: ["WEBVIEW_io.appium.android.apis"]
[AndroidDriver] Available contexts: ["NATIVE_APP","WEBVIEW_io.appium.android.apis"]
[W3C (d2d0b17c)] Responding to client with driver.getContexts() result: ["NATIVE_APP","WEBVIEW_io.appium.android.apis"]
[HTTP] <-- GET /wd/hub/session/d2d0b17c-fb8b-4422-93e3-a65e327eefdb/contexts 200 329 ms - 57

二、根据webview启动chromedriver

第二次调用webview脚本代码:

self.driver.switch_to.context(self.driver.contexts[-1])

日志分析:

2022-08-11 09:03:28:825 [HTTP] --> POST /wd/hub/session/d2d0b17c-fb8b-4422-93e3-a65e327eefdb/context
2022-08-11 09:03:28:825 [HTTP] {"name":"WEBVIEW_io.appium.android.apis"}
2022-08-11 09:03:28:826 [W3C (d2d0b17c)] Calling AppiumDriver.setContext() with args: ["WEBVIEW_io.appium.android.apis","d2d0b17c-fb8b-4422-93e3-a65e327eefdb"]
2022-08-11 09:03:28:826 [AndroidDriver] Getting a list of available webviews
2022-08-11 09:03:28:827 [ADB] Running '/Users/test/Library/Android/sdk/platform-tools/adb -P 5037 -s b1f37e8e shell cat /proc/net/unix'
2022-08-11 09:03:28:898 [AndroidDriver] Parsed 1 active devtools socket: ["@webview_devtools_remote_12270"]
2022-08-11 09:03:28:899 [AndroidDriver] Collecting CDP data of 1 webview
2022-08-11 09:03:28:899 [AndroidDriver] Forwarding remote port webview_devtools_remote_12270 to a local port in range 10900..11000
2022-08-11 09:03:28:899 [AndroidDriver] You could use the 'webviewDevtoolsPort' capability to customize the starting port number
2022-08-11 09:03:28:900 [ADB] Running '/Users/test/Library/Android/sdk/platform-tools/adb -P 5037 -s b1f37e8e forward tcp:10900 localabstract:webview_devtools_remote_12270'
2022-08-11 09:03:28:926 [ADB] Removing forwarded port socket connection: 10900 
2022-08-11 09:03:28:927 [ADB] Running '/Users/test/Library/Android/sdk/platform-tools/adb -P 5037 -s b1f37e8e forward --remove tcp:10900'
2022-08-11 09:03:28:945 [AndroidDriver] CDP data collection completed
2022-08-11 09:03:28:946 [AndroidDriver] WEBVIEW_12270 mapped to pid 12270
2022-08-11 09:03:28:946 [AndroidDriver] Getting process name for webview 'WEBVIEW_12270'
2022-08-11 09:03:28:946 [ADB] Running '/Users/test/Library/Android/sdk/platform-tools/adb -P 5037 -s b1f37e8e shell ps -A'
2022-08-11 09:03:29:061 [AndroidDriver] Got process name: 'io.appium.android.apis'
2022-08-11 09:03:29:062 [AndroidDriver] Found 1 webview: ["WEBVIEW_io.appium.android.apis"]
2022-08-11 09:03:29:062 [AndroidDriver] Available contexts: ["NATIVE_APP","WEBVIEW_io.appium.android.apis"]
2022-08-11 09:03:29:062 [AndroidDriver] Connecting to chrome-backed webview context 'WEBVIEW_io.appium.android.apis'
2022-08-11 09:03:29:064 [AndroidDriver] A port was not given, using random free port: 8000
2022-08-11 09:03:29:064 [AndroidDriver] Passing web view details to the Chromedriver constructor: {
2022-08-11 09:03:29:064 [AndroidDriver]   "info": {
2022-08-11 09:03:29:064 [AndroidDriver]     "Android-Package": "io.appium.android.apis",
2022-08-11 09:03:29:064 [AndroidDriver]     "Browser": "Chrome/92.0.4515.131",
2022-08-11 09:03:29:064 [AndroidDriver]     "Protocol-Version": "1.3",
2022-08-11 09:03:29:064 [AndroidDriver]     "User-Agent": "Mozilla/5.0 (Linux; Android 11; Redmi K30 5G Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/92.0.4515.131 Mobile Safari/537.36",
2022-08-11 09:03:29:064 [AndroidDriver]     "V8-Version": "9.2.230.22",
2022-08-11 09:03:29:064 [AndroidDriver]     "WebKit-Version": "537.36 (@6b8d6c56ce21e38a72f7c4becb5abc1fa5134f29)",
2022-08-11 09:03:29:064 [AndroidDriver]     "webSocketDebuggerUrl": "ws://127.0.0.1:10900/devtools/browser"
2022-08-11 09:03:29:065 [AndroidDriver]   },
2022-08-11 09:03:29:065 [AndroidDriver]   "process": {
2022-08-11 09:03:29:065 [AndroidDriver]     "name": "io.appium.android.apis",
2022-08-11 09:03:29:065 [AndroidDriver]     "id": "12270"
2022-08-11 09:03:29:065 [AndroidDriver]   }
2022-08-11 09:03:29:065 [AndroidDriver] }
2022-08-11 09:03:29:065 [AndroidDriver] Automated Chromedriver download is disabled. Use 'chromedriver_autodownload' server feature to enable it
2022-08-11 09:03:29:066 [AndroidDriver] Precalculated Chromedriver capabilities: {
2022-08-11 09:03:29:066 [AndroidDriver]   "androidPackage": "io.appium.android.apis",
2022-08-11 09:03:29:066 [AndroidDriver]   "androidUseRunningApp": true,
2022-08-11 09:03:29:066 [AndroidDriver]   "androidProcess": "io.appium.android.apis",
2022-08-11 09:03:29:067 [AndroidDriver]   "androidDeviceSerial": "b1f37e8e"
2022-08-11 09:03:29:067 [AndroidDriver] }
2022-08-11 09:03:29:067 [AndroidDriver] Before starting chromedriver, androidPackage is 'io.appium.android.apis'
2022-08-11 09:03:29:067 [Chromedriver] Changed state to 'starting'
2022-08-11 09:03:29:067 [Chromedriver] Attempting to use Chromedriver->Chrome mapping from '/Users/test/PycharmProjects/test_appium/testcase/mapping.json'
2022-08-11 09:03:29:069 [Chromedriver] The most recent known Chrome version: 104.0.5112
2022-08-11 09:03:29:072 [Chromedriver] Found 131 executables in '/Users/test/tools/chromedriverdir'
Chromedriver binary. Make sure it returns a valid version string in response to '--version/]' command line argument. spawn Unknown system error -86
2022-08-11 09:03:29:666 [Chromedriver] Cannot retrieve version number from 'mapping.json' Chromedriver binary. Make sure it returns a valid version string in response to '--version' command line argument. spawn /Users/gaozeyu/tools/chromedriverdir/mapping.json EACCES
2022-08-11 09:03:29:684 [Chromedriver] The following Chromedriver executables were found:
2022-08-11 09:03:29:689 [Chromedriver]     '/Users/test/tools/chromedriverdir/chromedriver-93-0-4577-63' (version '93.0.4577.63', minimum Chrome version '93.0.4577')
2022-08-11 09:03:29:689 [Chromedriver]     '/Users/test/tools/chromedriverdir/chromedriver-93-0-4577-15' (version '93.0.4577.15', minimum Chrome version '93.0.4577')
2022-08-11 09:03:29:689 [Chromedriver]     '/Users/test/tools/chromedriverdir/chromedriver-92-0-4515-107' (version '92.0.4515.107', minimum Chrome version '92.0.4515')
2022-08-11 09:03:29:689 [Chromedriver]     '/Users/test/tools/chromedriverdir/chromedriver-92-0-4515-43' (version '92.0.4515.43', minimum Chrome version '92.0.4515')
2022-08-11 09:03:29:695 [Chromedriver] Browser version in the supplied details: Chrome/92.0.4515.131
2022-08-11 09:03:29:695 [Chromedriver] Found Chrome bundle 'undefined' version '92.0.4515'
2022-08-11 09:03:29:696 [Chromedriver] Found 2 executables capable of automating Chrome '92.0.4515'.
2022-08-11 09:03:29:696 [Chromedriver] Choosing the most recent, '/Users/test/tools/chromedriverdir/chromedriver-92-0-4515-107'.
2022-08-11 09:03:29:696 [Chromedriver] If a specific version is required, specify it with the `chromedriverExecutable`desired capability.
2022-08-11 09:03:29:697 [Chromedriver] Set chromedriver binary as: /Users/gaozeyu/tools/chromedriverdir/chromedriver-92-0-4515-107
2022-08-11 09:03:29:697 [Chromedriver] Killing any old chromedrivers, running: pkill -15 -f "/Users/test/tools/chromedriverdir/chromedriver-92-0-4515-107.*--port=8000"
2022-08-11 09:03:29:735 [Chromedriver] No old chromedrivers seem to exist
2022-08-11 09:03:29:735 [Chromedriver] Cleaning this device\'s adb forwarded port socket connections: b1f37e8e
2022-08-11 09:03:29:735 [ADB] List forwarding ports
2022-08-11 09:03:29:735 [ADB] Running '/Users/test/Library/Android/sdk/platform-tools/adb -P 5037 -s b1f37e8e forward --list'
2022-08-11 09:03:29:752 [Chromedriver] Spawning chromedriver with: /Users/test/tools/chromedriverdir/chromedriver-92-0-4515-107 --url-base=wd/hub --port=8000 --adb-port=5037 --verbose
2022-08-11 09:03:29:764 [Chromedriver] Chromedriver version: '92.0.4515.107'
2022-08-11 09:03:29:765 [WD Proxy] Matched '/status' to command name 'getStatus'
2022-08-11 09:03:29:766 [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8000/wd/hub/status] with no body
2022-08-11 09:03:29:773 [WD Proxy] Got response with status 200: {"value":{"build":{"version":"92.0.4515.107 (87a818b10553a07434ea9e2b6dccf3cbe7895134-refs/branch-heads/4515@{#1634})"},"message":"ChromeDriver ready for new sessions.","os":{"arch":"x86_64","name":"Mac OS X","version":"12.3.1"},"ready":true}}
2022-08-11 09:03:29:773 [Chromedriver] Starting W3C Chromedriver session with capabilities: {
2022-08-11 09:03:29:773 [Chromedriver]   "capabilities": {
2022-08-11 09:03:29:773 [Chromedriver]     "alwaysMatch": {
2022-08-11 09:03:29:773 [Chromedriver]       "goog:chromeOptions": {
2022-08-11 09:03:29:773 [Chromedriver]         "androidPackage": "io.appium.android.apis",
2022-08-11 09:03:29:773 [Chromedriver]         "androidUseRunningApp": true,
2022-08-11 09:03:29:773 [Chromedriver]         "androidProcess": "io.appium.android.apis",
2022-08-11 09:03:29:773 [Chromedriver]         "androidDeviceSerial": "b1f37e8e"
2022-08-11 09:03:29:773 [Chromedriver]       },
2022-08-11 09:03:29:773 [Chromedriver]       "goog:loggingPrefs": {
2022-08-11 09:03:29:774 [Chromedriver]         "browser": "ALL"
2022-08-11 09:03:29:774 [Chromedriver]       }
2022-08-11 09:03:29:774 [Chromedriver]     }
2022-08-11 09:03:29:774 [Chromedriver]   }
2022-08-11 09:03:29:774 [Chromedriver] }
2022-08-11 09:03:29:774 [WD Proxy] Matched '/session' to command name 'createSession'
2022-08-11 09:03:29:774 [WD Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8000/wd/hub/session] with body: {"capabilities":{"alwaysMatch":{"goog:chromeOptions":{"androidPackage":"io.appium.android.apis","androidUseRunningApp":true,"androidProcess":"io.appium.android.apis","androidDeviceSerial":"b1f37e8e"},"goog:loggingPrefs":{"browser":"ALL"}}}}
2022-08-11 09:03:30:043 [Chromedriver] Webview version: 'Chrome/92.0.4515.131'
2022-08-11 09:03:30:102 [WD Proxy] Got response with status 200: {"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"92.0.4515.131","chrome":{"chromedriverVersion":"92.0.4515.107 (87a818b10553a07434ea9e2b6dccf3cbe7895134-refs/branch-heads/4515@{#1634})"},"goog:chromeOptions":{"debuggerAddress":"localhost:61565"},"pageLoadStrategy":"normal","platformName":"android","proxy":{},"setWindowRect":false,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify","webauthn:extension:credBlob":false,"webauthn:extension:largeBlob":false,"webauthn:virtualAuthenticators":false},"sessionId":"a650da032b9d8e2475052559bee24982"}}
2022-08-11 09:03:30:103 [WD Proxy] Determined the downstream protocol as 'W3C'
2022-08-11 09:03:30:103 [Chromedriver] Changed state to 'online'
2022-08-11 09:03:30:103 [W3C (d2d0b17c)] Responding to client with driver.setContext() result: null
2022-08-11 09:03:30:104 [HTTP] <-- POST /wd/hub/session/d2d0b17c-fb8b-4422-93e3-a65e327eefdb/context 200 1278 ms - 14
    1. 根据获取到的webview进程和进程ID,把参数传给chromedriver的构造器
2022-08-11 09:03:28:946 [AndroidDriver] WEBVIEW_12270 mapped to pid 12270
2022-08-11 09:03:28:946 [AndroidDriver] Getting process name for webview 'WEBVIEW_12270'
2022-08-11 09:03:28:946 [ADB] Running '/Users/test/Library/Android/sdk/platform-tools/adb -P 5037 -s b1f37e8e shell ps -A'
2022-08-11 09:03:29:061 [AndroidDriver] Got process name: 'io.appium.android.apis'
2022-08-11 09:03:29:062 [AndroidDriver] Found 1 webview: ["WEBVIEW_io.appium.android.apis"]
2022-08-11 09:03:29:062 [AndroidDriver] Available contexts: ["NATIVE_APP","WEBVIEW_io.appium.android.apis"]
2022-08-11 09:03:29:062 [AndroidDriver] Connecting to chrome-backed webview context 'WEBVIEW_io.appium.android.apis'
2022-08-11 09:03:29:064 [AndroidDriver] A port was not given, using random free port: 8000
2022-08-11 09:03:29:064 [AndroidDriver] Passing web view details to the Chromedriver constructor: {
2022-08-11 09:03:29:064 [AndroidDriver]   "info": {
2022-08-11 09:03:29:064 [AndroidDriver]     "Android-Package": "io.appium.android.apis",
2022-08-11 09:03:29:064 [AndroidDriver]     "Browser": "Chrome/92.0.4515.131",
2022-08-11 09:03:29:064 [AndroidDriver]     "Protocol-Version": "1.3",
2022-08-11 09:03:29:064 [AndroidDriver]     "User-Agent": "Mozilla/5.0 (Linux; Android 11; Redmi K30 5G Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/92.0.4515.131 Mobile Safari/537.36",
2022-08-11 09:03:29:064 [AndroidDriver]     "V8-Version": "9.2.230.22",
2022-08-11 09:03:29:064 [AndroidDriver]     "WebKit-Version": "537.36 (@6b8d6c56ce21e38a72f7c4becb5abc1fa5134f29)",
2022-08-11 09:03:29:064 [AndroidDriver]     "webSocketDebuggerUrl": "ws://127.0.0.1:10900/devtools/browser"
2022-08-11 09:03:29:065 [AndroidDriver]   },
2022-08-11 09:03:29:065 [AndroidDriver]   "process": {
2022-08-11 09:03:29:065 [AndroidDriver]     "name": "io.appium.android.apis",
2022-08-11 09:03:29:065 [AndroidDriver]     "id": "12270"
2022-08-11 09:03:29:065 [AndroidDriver]   }
2022-08-11 09:03:29:065 [AndroidDriver] }
2022-08-11 09:03:29:065 [AndroidDriver] Automated Chromedriver download is disabled. Use 'chromedriver_autodownload' server feature to enable it
2022-08-11 09:03:29:066 [AndroidDriver] Precalculated Chromedriver capabilities: {
2022-08-11 09:03:29:066 [AndroidDriver]   "androidPackage": "io.appium.android.apis",
2022-08-11 09:03:29:066 [AndroidDriver]   "androidUseRunningApp": true,
2022-08-11 09:03:29:066 [AndroidDriver]   "androidProcess": "io.appium.android.apis",
2022-08-11 09:03:29:067 [AndroidDriver]   "androidDeviceSerial": "b1f37e8e"
2022-08-11 09:03:29:067 [AndroidDriver] }
    1. 根据chromedriverChromeMappingFile定义的mapping文件,在chromedriverExecutableDir定义的目录中查找对应app中chromedriver版本
2022-08-11 09:03:29:067 [Chromedriver] Changed state to 'starting'
2022-08-11 09:03:29:067 [Chromedriver] Attempting to use Chromedriver->Chrome mapping from '/Users/test/PycharmProjects/test_appium/testcase/mapping.json'
2022-08-11 09:03:29:069 [Chromedriver] The most recent known Chrome version: 104.0.5112
2022-08-11 09:03:29:072 [Chromedriver] Found 131 executables in '/Users/test/tools/chromedriverdir'
Chromedriver binary. Make sure it returns a valid version string in response to '--version/]' command line argument. spawn Unknown system error -86
2022-08-11 09:03:29:666 [Chromedriver] Cannot retrieve version number from 'mapping.json' Chromedriver binary. Make sure it returns a valid version string in response to '--version' command line argument. spawn /Users/gaozeyu/tools/chromedriverdir/mapping.json EACCES
2022-08-11 09:03:29:684 [Chromedriver] The following Chromedriver executables were found:
2022-08-11 09:03:29:689 [Chromedriver]     '/Users/test/tools/chromedriverdir/chromedriver-93-0-4577-63' (version '93.0.4577.63', minimum Chrome version '93.0.4577')
2022-08-11 09:03:29:689 [Chromedriver]     '/Users/test/tools/chromedriverdir/chromedriver-93-0-4577-15' (version '93.0.4577.15', minimum Chrome version '93.0.4577')
2022-08-11 09:03:29:689 [Chromedriver]     '/Users/test/tools/chromedriverdir/chromedriver-92-0-4515-107' (version '92.0.4515.107', minimum Chrome version '92.0.4515')
2022-08-11 09:03:29:689 [Chromedriver]     '/Users/test/tools/chromedriverdir/chromedriver-92-0-4515-43' (version '92.0.4515.43', minimum Chrome version '92.0.4515')
2022-08-11 09:03:29:695 [Chromedriver] Browser version in the supplied details: Chrome/92.0.4515.131
2022-08-11 09:03:29:695 [Chromedriver] Found Chrome bundle 'undefined' version '92.0.4515'
2022-08-11 09:03:29:696 [Chromedriver] Found 2 executables capable of automating Chrome '92.0.4515'.
2022-08-11 09:03:29:696 [Chromedriver] Choosing the most recent, '/Users/test/tools/chromedriverdir/chromedriver-92-0-4515-107'.
    1. 匹配版本完成后,先kill掉对应版本的chromedriver进程,然后以默认8000端口,启动chromedriver
2022-08-11 09:03:29:697 [Chromedriver] Killing any old chromedrivers, running: pkill -15 -f "/Users/test/tools/chromedriverdir/chromedriver-92-0-4515-107.*--port=8000"
2022-08-11 09:03:29:735 [Chromedriver] No old chromedrivers seem to exist
2022-08-11 09:03:29:735 [Chromedriver] Cleaning this device\'s adb forwarded port socket connections: b1f37e8e
2022-08-11 09:03:29:735 [ADB] List forwarding ports
2022-08-11 09:03:29:735 [ADB] Running '/Users/test/Library/Android/sdk/platform-tools/adb -P 5037 -s b1f37e8e forward --list'
2022-08-11 09:03:29:752 [Chromedriver] Spawning chromedriver with: /Users/test/tools/chromedriverdir/chromedriver-92-0-4515-107 --url-base=wd/hub --port=8000 --adb-port=5037 --verbose
2022-08-11 09:03:29:764 [Chromedriver] Chromedriver version: '92.0.4515.107'
    1. 本地的get Status和启动的8000/status进行映射,获取状态
2022-08-11 09:03:29:765 [WD Proxy] Matched '/status' to command name 'getStatus'
2022-08-11 09:03:29:766 [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8000/wd/hub/status] with no body
2022-08-11 09:03:29:773 [WD Proxy] Got response with status 200: {"value":{"build":{"version":"92.0.4515.107 (87a818b10553a07434ea9e2b6dccf3cbe7895134-refs/branch-heads/4515@{#1634})"},"message":"ChromeDriver ready for new sessions.","os":{"arch":"x86_64","name":"Mac OS X","version":"12.3.1"},"ready":true}}
    1. 本地的createSession与/session进行映射,根据capabilities参数创建session,,返回sessionId
2022-08-12 08:05:05:762 [Chromedriver] Starting W3C Chromedriver session with capabilities: {
2022-08-12 08:05:05:762 [Chromedriver]   "capabilities": {
2022-08-12 08:05:05:762 [Chromedriver]     "alwaysMatch": {
2022-08-12 08:05:05:762 [Chromedriver]       "goog:chromeOptions": {
2022-08-12 08:05:05:762 [Chromedriver]         "androidPackage": "io.appium.android.apis",
2022-08-12 08:05:05:762 [Chromedriver]         "androidUseRunningApp": true,
2022-08-12 08:05:05:762 [Chromedriver]         "androidProcess": "io.appium.android.apis",
2022-08-12 08:05:05:762 [Chromedriver]         "androidDeviceSerial": "b1f37e8e"
2022-08-12 08:05:05:763 [Chromedriver]       },
2022-08-12 08:05:05:763 [Chromedriver]       "goog:loggingPrefs": {
2022-08-12 08:05:05:763 [Chromedriver]         "browser": "ALL"
2022-08-12 08:05:05:763 [Chromedriver]       }
2022-08-12 08:05:05:763 [Chromedriver]     }
2022-08-12 08:05:05:763 [Chromedriver]   }
2022-08-12 08:05:05:763 [Chromedriver] }
2022-08-12 08:05:05:763 [WD Proxy] Matched '/session' to command name 'createSession'
2022-08-12 08:05:05:763 [WD Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8000/wd/hub/session] with body: {"capabilities":{"alwaysMatch":{"goog:chromeOptions":{"androidPackage":"io.appium.android.apis","androidUseRunningApp":true,"androidProcess":"io.appium.android.apis","androidDeviceSerial":"b1f37e8e"},"goog:loggingPrefs":{"browser":"ALL"}}}}
2022-08-12 08:05:06:031 [Chromedriver] Webview version: 'Chrome/92.0.4515.131'
2022-08-12 08:05:06:101 [WD Proxy] Got response with status 200: {"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"92.0.4515.131","chrome":{"chromedriverVersion":"92.0.4515.107 (87a818b10553a07434ea9e2b6dccf3cbe7895134-refs/branch-heads/4515@{#1634})"},"goog:chromeOptions":{"debuggerAddress":"localhost:59524"},"pageLoadStrategy":"normal","platformName":"android","proxy":{},"setWindowRect":false,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify","webauthn:extension:credBlob":false,"webauthn:extension:largeBlob":false,"webauthn:virtualAuthenticators":false},"sessionId":"02fc7705e267e9cc53a63f8500b68c7e"}
2022-08-12 08:05:06:102 [WD Proxy] Determined the downstream protocol as 'W3C'
2022-08-12 08:05:06:102 [Chromedriver] Changed state to 'online'
2022-08-12 08:05:06:102 [WD Proxy] Determined the downstream protocol as 'W3C'
2022-08-12 08:05:06:102 [Chromedriver] Changed state to 'online'
2022-08-12 08:05:06:102 [W3C (f90fdb4c)] Responding to client with driver.setContext() result: null
2022-08-12 08:05:06:103 [HTTP] <-- POST /wd/hub/session/f90fdb4c-ffed-4ba3-8b38-b9e2c986f357/context 200 1543 ms - 14
    1. 后续日志为元素定位,与web端一致

总结

appium操作webview基本就是接受客户端的请求,然后appium-server把请求转发给chrome-driver,进行操作,底层还是selenium

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

APP自动化测试-11.webview技术原理 的相关文章

随机推荐

  • JAVA图片压缩

    图片压缩代码操作 需要压缩的原图片路径为 src 压缩后存放的路径为 dist 需要压缩的宽度为 width 需要压缩的后的高度为 height File srcfile new File src 原图片是否存在 if srcfile ex
  • python几个轻量级web框架

    我最近发表了一篇名为 7 Minimal Node js Web Frameworks for 2014 and Beyond 的博文 目前它是我博客访问量最高的文章 超过10000人浏览 分享和评论了这些我总结到一起的web框架 这教会了
  • 金晟富:4.17黄金冲高遇阻急需调整!后市黄金原油操作建议

    前言导读 各位投资朋友 转眼间又到周末了 祝大家周末愉快 此刻的你还在到处看文章找策略吗 不知晟富每日及时给到你的现价单你关注了多少呢 每天的多空是否让你犹豫再犹豫 一单损完又害怕下一单 如果你还在迷茫犹豫的道路上 不妨可留意下金晟富的文章
  • simulink中PID控制器搭建

    Simulink 是一个用于仿真 建模和仿真的软件工具 您可以在其中搭建 PID 控制器 以下是如何搭建一个简单的 PID 控制器的步骤 启动 Simulink 打开一个新模型 在模型窗口中插入一个 PID 控制器 模块 可以在 Simul
  • STM32 电机教程 1 - 用ST Motor Profiler 测量无刷电机参数

    前言 在对电机进行控制前 往往需要先知道电机的一些参数 但是在实际应用过程中 经常会出现在控制一个电机参 但对电机的参数如相电阻电感的参数不够了解的情况 本节给大家演示基本ST Motor Profiler测量电机参数的操作过程 让大家在以
  • Spring Cloud 与 Dubbo 区别

    1 定位点不同 SpringCloud SpirngCloud 定位为微服务架构下的一站式解决方案 Dubbo 关注点主要在于服务的调用 流量分发 流量监控和熔断 2 dubbo基于rpc 底层netty SpirngCloud基于http
  • 【点云处理之论文狂读前沿版7】—— Masked Autoencoders for Point Cloud Self-supervised Learning

    Masked Autoencoders for Point Cloud Self supervised Learning 摘要 1 引言 3 Point MAE 3 1 Point Cloud Masking and Embedding 3
  • Docker专题(八)-Docker-Docker部署SpringBoot项目

    1 手工方式 1 1 准备Springboot jar项目 将项目打包成jar 1 2 编写Dockerfile FROM java 8 VOLUME tmp ADD elk web 1 0 SNAPSHOT jar elk jar EXP
  • PhpStorm最全攻略

    本教程主要内容的是日常开发 测试 部署工作流的一些技巧和工具配置方法 并尽量将最有用的部分提取出来并结合实际场景做介绍 而并不是仅仅对PhpStorm的功能的简单罗列 如果读者有改善的建议 可以在教程下方留言或直接与作者联系 共同促进内容的
  • 工具:npm/node版本更换(Windows版本) 含报错exit status 1报错,出现乱码的解决方法

    npm版本更换 更换指定版本 npm g install npm 6 14 11 更换最新版本 npm install g npm node版本更换 方法1 下载nvm https www runoob com w3cnote nvm ma
  • 腾讯业务百万数据 6s 响应,APIJSON 性能优化背后的故事

    最近发生了一件大事儿 APIJSON 再也不用担心被人质疑性能问题了哈哈 某周三腾讯 CSIG 某项目组 已经用 APIJSON 做完一期 突然反馈了查询大量数据性能急剧下降的情况 某张表 2 3KW 记录 用 APIJSON 万能通用接口
  • 【数据库-4】clinvar

    欢迎关注公众号 oddxix 如果觉得写的不错记得点个赞哦 留步看一下这个讲解视频吧 https v qq com x page m03789y9j98 html 搭配这个pdf食用更佳哦 https www clinicalgenome
  • 动态规划的实践

    一 动态规划要解决的问题 动态规划问题的一般形式就是求最值 动态规划其实是运筹学的一种最优化方法 只不过在计算机问题上应用比较多 比如说让你求最长递增子序列 背包问题呀等 只要我们发现某一过程包含多种状态 情况 后一种状态的生成依赖于前面的
  • 七天LLVM零基础入门(Linux版本)------第四天

    作者 snsn1984 第一步 复习 第三天的时候 我们学习了LLVM的编程指引 在开始第四天的学习之前 需要复习之前学习过的两篇文档 LLVM IR的文档 http llvm org docs LangRef html 编程指引文档 ht
  • 使用spyder3调试python程序的简明教程

    说是简明教程 其实是我自己尝试用spyder调试python程序的过程的一个记录 因为spyder的调试功能是基于pdb 而我又没有pdb的基础 所以刚开始上手时感觉很不习惯 而且那时我又很懒 没去找官方文档 仅仅在百度和csdn上找了找
  • 腾讯云被ddos攻击解决方案

    腾讯云是国内仅此次阿里云的云服务商 很多创业者都使用他们家云服务器 自然被DDOS攻击的也不少 今天来介绍下使用腾讯云服务器被DDOS攻击的解决办法 一 购买腾讯高防IP 也称腾讯大禹BGP高防IP 是一个运行在腾讯云内网的高防IP服务 适
  • nginx (1):ubuntu下安装启动nginx

    1 安装依赖 sudo apt get install gcc zlib1g dev libpcre3 libpcre3 dev libssl dev 2 下载nginx wget https nginx org download ngin
  • 【vue 页面下滚到目标元素的位置,目标元素自动吸顶(自动悬浮吸附到页面顶部)】

    vue 页面下滚到目标元素的位置 目标元素自动吸顶 自动悬浮吸附到页面顶部 原文链接 https blog csdn net weixin 41192489 article details 112320596 1 监听页面滚动事件 监听页面
  • xxl-job(2.4.1)使用spring-mvc替换netty的功能

    xxl job 2 4 1 使用spring mvc替换netty的功能 1 xxl job core引入spring mvc的依赖
  • APP自动化测试-11.webview技术原理

    APP自动化测试 11 webview技术原理 文章目录 APP自动化测试 11 webview技术原理 前言 一 获取webview 二 根据webview启动chromedriver 总结 前言 根据日志 简单记录webview运行的机