Appium Inspector 复制界面的文字,携带了很多不需要的html标签

Appium Inspector 复制界面的文字,携带了很多不需要的html标签
比如我要复制Appium Inspector界面的元素id 或者xpath ,几乎任何文字,粘贴后都是带了一大堆不需要的html标签

是的,这是因为 Appium Inspector 使用了 HTML 标签来渲染界面和显示元素信息。要从中提取出纯文本,您可以使用一些文本编辑工具或脚本来清除 HTML 标签。

以下是使用 Python 进行文本清理的示例代码:

from bs4 import BeautifulSoup

html_text = '<div><p>This is <strong>some</strong> text</p></div>'
soup = BeautifulSoup(html_text, 'html.parser')
clean_text = soup.get_text()
print(clean_text)


这段代码将 HTML 文本

This is some text

转换为纯文本 This is some text。