当前位置:网站首页>Appium automated testing, instance sharing
Appium automated testing, instance sharing
2022-07-23 05:47:00 【zsyzcsan】
appium automated testing , Instance to share .
This article is about the postgraduate entrance examination gang .apk Automatic script development of login function .
Three steps :
1、 Element localization
【 Some element positioning is pasted here , For example 】
Click agree ( Clause ):
com.tal.kaoyan:id/tip_commit
Click to skip :
com.tal.kaoyan:id/tv_skip
Login screen , Click password to log in
com.tal.kaoyan:id/login_code_touname
Click on the user name / Email input box , And the reference
com.tal.kaoyan:id/login_email_edittext
Click the password input box , And the reference
com.tal.kaoyan:id/login_password_edittext
Click login
com.tal.kaoyan:id/login_login_btn
2、 We put capability The configuration file is encapsulated in capability20201106.py, For business scripts appium20201106-01.py call ;
from appium import webdriver
import time
def capability_config():
desired_caps = {
"platformName": "Android",
"deviceName": "127.0.0.1:52001",
"platforVersion": "5.1.1",
"app": r"F:\1python\kaoyanbang_3.7.4.297.apk",
"appPackage": "com.tal.kaoyan",
"appActivity": "com.tal.kaoyan.ui.activity.SplashActivity",
"unicodekeyboard": "True", # Solve the problem of Chinese coding
"resetkeybodar": "True", # Patron saint of IME
# "noReset": "true"
"noReset": "false"
}
# driver = webdriver.Remote("http://127.0.0.1:4444/wd/hub", desired_caps)
driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desired_caps)
driver.implicitly_wait(5) # An implicit wait
return driver
#capability_config()
3、appium20201106-01.py It's a business script ; Here we are py Prepare the postgraduate entrance examination help in the document apk Login code
from appium import webdriver
from find_element20201106.capability20201106 import capability_config
import time
from selenium.common.exceptions import NoSuchElementException
# # Click on “ Not used temporarily ” User information protection and privacy clauses
# el1 = driver.find_element_by_id("com.tal.kaoyan:id/tip_cancle")
# el1.click()
driver = capability_config()
print(" The journey is about to begin ...")
# time.sleep(120)
# Click on “ agree! ” Clause
def check_tk():
print(" Check whether there are elements of the agreement clause ")
try:
tiaokuan = driver.find_element_by_id("com.tal.kaoyan:id/tip_commit")
except NoSuchElementException:
print(" Check for elements that do not agree with the terms , Normal skip ")
else:
print(" Check the element of the agreement clause , About to click this element .....")
tiaokuan.click()
driver.implicitly_wait(30)
def check_skip():
print(" Check whether there are upgraded elements ")
try:
r_skip = driver.find_element_by_id("com.tal.kaoyan:id/tv_skip")
except NoSuchElementException:
print(" No skipping elements ")
else:
print(" About to click the skip button ")
r_skip.click()
driver.implicitly_wait(30)
def login():
name_login = driver.find_element_by_id("com.tal.kaoyan:id/login_code_touname")
name_login.click()
name_input = driver.find_element_by_id("com.tal.kaoyan:id/login_email_edittext")
name_input.clear()
name_input.send_keys("username")
passwd_input = driver.find_element_by_id("com.tal.kaoyan:id/login_password_edittext")
passwd_input.clear()
passwd_input.send_keys("passwd")
login_btn = driver.find_element_by_id("com.tal.kaoyan:id/login_login_btn")
login_btn.click()
print(" Wrong user name or password , Please re-enter ..... Game over ")
driver.close_app()
print("app Closed successfully ")
# print(" About to enter user name ")
# el1 = driver.find_element_by_id("com.tal.kaoyan:id/kylogin_phone_input_phonenum")
# el1.send_keys("18888888888")
# print(" About to enter the verification code ")
# el2 = driver.find_element_by_id("com.tal.kaoyan:id/kylogin_phone_input_code")
# el2.send_keys("1234")
check_tk()
check_skip()
login()
边栏推荐
猜你喜欢
随机推荐
VR专业的面试题你都见过没?相信我绝对有用
软件bug
超简单的倒计时代码编写
App自动化测试是怎么实现H5测试的
一个简易的手机端todo
用两个栈实现一个队列。
电商网站开发建设功能分析
appium-doctor命令错误入坑-已解决
A2-1 use STB_ Image.h to draw and display pictures
使用清华镜像安装librosa
Structure and development layering of games104 b1+b2 engine
链表 题目合集
DOM - node operation (I)
深入浅出掌握接口自动化-01
GAMES104 B1+B2 引擎的结构与开发分层
Epoll use case details
Compile and install redis-6.2.5 under Windows
动态规划A-1
电影推荐系统
RPC-BDY(2)-注册多个服务









