python+appium清空文本框内容
import os
import unittest
from appium import webdriver
# from selenium import webdriver
from appium.webdriver.common.touch_action import TouchAction
from appium.webdriver.common.multi_action import MultiAction
from time import sleepPATH = lambda p: os.path.abspath(
os.path.join(os.path.dirname(__file__), p)
)
class LoginTest(unittest.TestCase):
def setUp(self):
desired_caps = {}
desired_caps['platformName'] = 'Android'
# 设置android系统版本
desired_caps['platformVersion'] = '6.0'
# desired_caps['deviceName'] = '777f90cb'
desired_caps['deviceName'] = 'RKHQFYPN99999999'
# 为true时,手机中存在引用apk,不再次安装apk
desired_caps['autoLaunch'] = 'true'# 是否自动启动
desired_caps['noReset'] = 'true'
desired_caps['newCommandTimeout'] = 20
# 设置apk的路径
desired_caps['app'] = PATH( 'D:\\App_TESTNG\\apps\\BiClubApp_v1.3.0.apk')
# 设置APK包名和类名
desired_caps['noReset'] = 'True'
desired_caps['appPackage'] = 'com.chainedin.io.BiClubApp'
desired_caps['appActivity'] = 'md570526dd7b8d9fe1e7e27ecbd3279627a.SplashScreen'
# 重置输入法为系统默认
desired_caps['resetKeyboard'] = 'true'
# support Chinese支持中文输入
desired_caps['unicodeKeyboard'] = 'true'
desired_caps['noSign'] = 'true'
# Returns abs path relative to this file and not cwdself.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)def tearDown(self):
self.driver.quit()def editClear(self, text):
#123代表光标移动到末尾
self.driver.keyevent(123)
for i in range(0, len(text)):
#67退格键
self.driver.keyevent(67)def test_find_elements(self):
# pause a moment, so xml generation can occur
sleep(2)
print("点击法币")
fb = self.driver.find_element_by_xpath("//android.view.View/android.widget.FrameLayout[3]/android.widget.ImageView[1]")
fb.click()
sleep(2)
print("点击注册登录")
zcdl = self.driver.find_element_by_xpath("//android.widget.Button[@text='登录/注册']")
zcdl.click()
sleep(3)
print("输入用户名")
# username = self.driver.find_element_by_xpath("//android.view.View/android.view.View[1]/android.view.View[1]/android.view.View[2]/android.view.View[1]/android.view.View[1]/android.view.View[1]/android.view.View[1]")
qk = self.driver.find_element_by_xpath("//android.widget.EditText[@text='17800000020']").text
username = self.driver.find_element_by_xpath("//android.widget.EditText[@text='17800000020']")
username.click()
#123移动光标至末尾
self.driver.keyevent(123)
for i in range(0, len(qk)):
#67退格键
self.driver.keyevent(67)
sleep(2)
username.send_keys(17800000020)
sleep(2)
print("输入密码")
password = self.driver.find_element_by_xpath("//android.view.View/android.view.View[1]/android.view.View[1]/android.view.View[2]/android.view.View[1]/android.view.View[1]/android.view.View[2]/android.view.View[1]")
password.click()
password.send_keys("123456")sleep(3)
print("点击登录按钮")
dl = self.driver.find_element_by_xpath("//android.widget.Button[@text='登录']")
dl.click()
sleep(3)
print("输入验证码")
yzm = self.driver.find_element_by_xpath("//android.view.View/android.view.View[2]/android.view.View[1]/android.view.View[2]/android.widget.EditText[1]")
yzm.send_keys(123456)
sleep(2)
print("点击确认按钮")
qr = self.driver.find_element_by_xpath("//android.widget.Button[@text='确认']")
qr.click()
sleep(2)
print("点击暂不设置")
bsz = self.driver.find_element_by_xpath("//android.widget.TextView[@text='暂不设置']")
bsz.click()
if __name__ == '__main__':
unittest.main()
【python+appium清空文本框内容】环境:selenium+python3.5
所有内容均为一字一字码出来的,转载麻烦标明链接哦,谢谢~https://mp.csdn.net/postedit/84063814
推荐阅读
- 第二阶段day1总结
- 误删/清空.bashrc文件/内容
- iOS富文本为html时,修改默认字体颜色
- 23-2-2020|23-2-2020 收納與整理(10)
- Mac下怎么新建|Mac下怎么新建 .txt 文本文件
- 使用NSAttributedString富文本踩到的坑
- python清空文件内容
- Android将文本中的URL转换为超链接工具类(原文本有超链接标签也适用)
- r语言|手把手(R语言文本挖掘和词云可视化实践)
- 论文查重python文本相似性计算simhash源码