appium-操作webview

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()

相关文章

前言:appium可以说是app最火的一个自动化框架,它的主要优势...
(原文:https://www.cnblogs.com/fancy0158/p/10047906.htm...
一Appium介绍1.1含义开源,跨平台,多语言支持的移动应用自动...
前言:Appium是一个自动化测试开源工具,支持iOS平台和Andro...
转:https://blog.csdn.net/Tigerdong1/article/details/801...
(原文:https://www.cnblogs.com/fancy0158/p/10056418.htm...