2013-10-10 59 views
0

我想要使用python從我的apk中選擇一個元素。它總是返回空返回。這是我的代碼。爲什麼我無法從我的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") 
+0

os.path.abspath則(os.path.dirname(os.path.realpath(__ FILE__))) – user2753523

回答

0
os.path.abspath(os.path.dirname(os.path.realpath(__file__))) 
相關問題