admin管理员组文章数量:1308024
I am trying to automate some flow in UIAutomator
and a part of it has been to press the copy button on an app, after pressing this copy button I would need to access the copied content in code via python UIAutomator
... how do I do so?
COPY_KEY = {
CLASS_NAME: "android.widget.Button",
DESCRIPTION: "Copy key"
}
self.DEVICE.get_element(self.COPY_KEY).click()
clean_seed = 'copied code'
I am trying to automate some flow in UIAutomator
and a part of it has been to press the copy button on an app, after pressing this copy button I would need to access the copied content in code via python UIAutomator
... how do I do so?
COPY_KEY = {
CLASS_NAME: "android.widget.Button",
DESCRIPTION: "Copy key"
}
self.DEVICE.get_element(self.COPY_KEY).click()
clean_seed = 'copied code'
Share
Improve this question
edited Feb 3 at 16:33
globglogabgalab
4493 silver badges14 bronze badges
asked Feb 2 at 7:24
aherlambangaherlambang
14.4k54 gold badges153 silver badges255 bronze badges
1 Answer
Reset to default 0Accessing copied text via Python UIAutomator2 typically boils down to reading system clipboard on Android device after you have triggered the Copy
action.Currently UIAutomator2
does not provide built-in get clipboard
method in all versions so most reliable approach is to use an ADB shell command via the `device.shell(...) interface
You can use am get-clipboard (Android 10+)
import uiautomator2 as u2
d = u2.connect()
d(resourceId="com.example:id/my_copy_button").click()
copied_text = d.shell("am get-clipboard").strip()
print("Copied text:", copied_text)
本文标签: how to access copied content in python UIAutomator2Stack Overflow
版权声明:本文标题:how to access copied content in python UIAutomator2 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741854308a2401249.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论