import time
from appium import webdriver
from appium.webdriver.common.mobileby import MobileBy
from appium.webdriver.common.touch_action import TouchAction
from selenium.webdriver.support.wait import webdriverwait
from selenium.webdriver.support import expected_conditions as EC
# adb devices
# adb connect 127.0.0.1:62001
# 1 手机的配置信息
info = {
# "automationName": "UIAutomator2",
# 1 测试的平台
"platformName": "Android",
# 2 版本号 关于 -- 版本号
"platformVersion": "7.1.2",
# 3 设备名
"deviceName": "127.0.0.1:62001",
"appPackage": "com.vy.visvacn",
# 界面名称
"appActivity": "com.vy.visvacn.module.splash.SplashActivity",
"noreset": True
}
# 启动程序
driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", info)
# 等待webview元素出现
webdriverwait(driver, 20). \
until(EC.visibility_of_element_located((MobileBy.ANDROID_UIAUTOMATOR, 'New UiSelector().text("")')))
time.sleep(1)
cons = driver.contexts # 获取上下文
print(cons)
driver.switch_to.context(cons[-1]) # 切换上下文
webdriverwait(driver, 20).until(EC.visibility_of_element_located(MobileBy.XPATH, ""))
driver.find_element(MobileBy.XPATH, "").click()
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。