Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[功能增强,不是bug] 关于支持app内webview的操作和录制 #1211

Open
lzus opened this issue Apr 30, 2024 · 0 comments
Open

[功能增强,不是bug] 关于支持app内webview的操作和录制 #1211

lzus opened this issue Apr 30, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@lzus
Copy link

lzus commented Apr 30, 2024

不知道airtest的大牛们是否能增强一下airtest的webview功能?一个是关于app内webview的操作,一个是关于app内webview的录制

【背景】看了https://airtest.doc.io.netease.com/IDEdocs/poco_framework/poco_webview/, airtest对于app内的webview是依靠系统把webview映射成native来操作,然后用native来操作,但是很多场景下其实是需要操作webview元素;

Appium框架是支持操作app内webview元素的,原理和操作大致是

  1. pc上启动一个chromedriver ,用adb做转发
    chromedriver --url-base=wd/hub --port=8000 --adb-port=5037 --verbose

  2. 自动化脚本设置selenium参数,依靠adb转发请求到手机app内的webview
    ` from selenium import webdriver
    options = webdriver.ChromeOptions()
    #指定连接的app
    options.add_experimental_option('androidPackage', 'com.lowcode.testapp.andr')
    options.add_experimental_option('androidProcess', 'com.lowcode.testapp.andr')
    options.add_experimental_option('androidUseRunningApp', True)
    #指定连接的手机
    options.add_experimental_option('androidDeviceSerial', '55264ffe1220')

    d = options.to_capabilities()

    driver = webdriver.Remote(command_executor="http://127.0.0.1:8000/wd/hub", desired_capabilities=d)
    sleep(5)
    #连接后就可以操作webview内元素了
    driver.find_element_by_id("kw").click()`

原理相对简单,

【增强1】是否可修改airtest中selenium的框架去支持操作手机app内的webview(H5)?

【增强2】操作app内的webview相对好说,非airtest的开发人员也可以打补丁实现; 但是录制还是不行,现在airtest用selenium录制是直接打开pc上的浏览器,我看录制介绍的原理如下图,好像是airtest用dev tools协议连接浏览器,获取浏览器上的操作解释成脚本。
那么是否可以再让airtest用devtools协议连接手机app内的webview? 这样在手机上操作也能录制webview脚本了。

不管如何,先行感谢您耐心读完此帖!

image
@yimelia yimelia added the enhancement New feature or request label May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants