遇到了跟您一样的问题,请问解决了吗?
#-*- coding:utf-8 -*-
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.2'
#路径改了
desired_caps['app'] = PATH('ContactManager.apk')
#什么意思?
desired_caps['app-package'] = 'com.example.android.contactmanager'
#什么意思?
desired_caps['app-activity'] = '.ContactManager'
#什么意思
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
#找到添加按钮?
el = driver.find_element_by_name("Add Contact")
#点击button
el.click()
#
textfields = driver.find_elements_by_tag_name("textfield")
#添加
textfields[0].send_keys("GENGJIKUN")
#添加
textfields[1].send_keys("15201558593")
#添加
textfields[2].send_keys("jikunshishen@163.com")
#点击保存
driver.find_element_by_name("Save").click()
#退出
driver.quit()
能帮我添下注释么?
#12 楼 @lihuazhang 我就是太粗心了~ 谢谢了哈
#-*- coding:utf-8 -*-
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.2'
#路径改了
desired_caps['app'] = PATH('ContactManager.apk')
desired_caps['app-package'] = 'com.example.android.contactmanager'
desired_caps['app-activity'] = '.ContactManager'
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
el = driver.find_element_by_name("Add Contact")
el.click()
textfields = driver.find_elements_by_tag_name("textfield")
textfields[0].send_keys("My Name")
textfields[2].send_keys("someone@somewhere.com")
driver.find_element_by_name("Save").click()
driver.quit()
成功了~谢谢!我太粗心了~