appium之滑动屏幕+判断元素是否存在+截图+toast定位
基础代码
import time
from appium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
server = 'http://localhost:4723/wd/hub'
caps = {
"platformName": "Android",
"deviceName": "JPF4C19123011893",
"platformVersion": "10.0",
"appPackage": "com.czb.webczbdemo",
"appActivity": "com.czb.webczbdemo.MainActivity",
"automationName": "uiautomator2",
"noReset": "true",
"unicodeKeyboard": "true",
"resetKeyboard": "true"
}
driver = webdriver.Remote(server, caps)
wait = WebDriverWait(driver, 30)
#通过find_element_by_id来获取元素
navigation_button = driver.find_element_by_id("com.czb.webczbdemo:id/webNavigation")
#点击元素
navigation_button.click()
#等待3秒
time.sleep(3)
#通过find_element_by_class_name来定位元素
edit_text = driver.find_element_by_class_name("android.widget.EditText")
#将元素中的内容清空
edit_text.clear()
#等待3秒
time.sleep(3)
#将新的地址放到输入框中
edit_text.send_keys("https://test-open.czb365.com/redirection/todo/?platformType=92611011&platformCode=18610899775")
#通过find_element_by_class_name来定位元素
commit_button = driver.find_element_by_class_name("android.widget.Button")
#点击前往按钮
commit_button.click()
#通过find_elements来查找有相同定位信息的一组元素
o

最低0.47元/天 解锁文章
2733

被折叠的 条评论
为什么被折叠?



