为什么我不能从APK中选择元素?

2021-11-29 22:14:16 发布

您现在位置:Python中文网/ 问答频道 /正文

我想使用python从apk中选择一个元素。它总是返回空返回。这是我的密码。你知道吗

import os
from selenium import webdriver

# Returns abs path relative to this file and not cwd
PATH = lambda p: os.path.abspath(
    os.path.join(os.path.dirname(__file__), p)
)

desired_caps = {}
desired_caps['device'] = 'Android'
desired_caps['browserName'] = ''
desired_caps['version'] = '4.2'
desired_caps['app'] = PATH('/home/user/Desktop/abs.apk')
desired_caps['app-package'] = 'lk.xyz.abs'
desired_caps['app-activity'] = '.abs'

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

textfields = driver.find_elements_by_tag_name("input")
textfields[1].send_keys("observer")
textfields[2].send_keys("test")