app中有webview的情况
手机淘宝的天猫国际页面是一个webview
robotframework代码:
*** Settings *** Suite Setup Suite Teardown Library AppiumLibrary *** Variables *** *** Test Cases *** 手机淘宝 Open Application http://localhost:4723/wd/hub platformName=Android platformVersion=19 deviceName=emulator-5554 app=${CURDIR}${/}shoujitaobao_178.apk appPackage=com.taobao.taobao ... appActivity=com.taobao.tao.welcome.Welcome unicodeKeyboard=True resetKeyboard=True Wait Until Page Contains Element xpath=//android.widget.TextView[@text="天猫国际"] Click Element xpath=//android.widget.TextView[@text="天猫国际"] @{contexts} Get Contexts Log Many @{contexts} ${cur_context} Get Current Context log 当前context log ${cur_context} log 开始切换 Switch To Context WEBVIEW_com.taobao.taobao log 切换成功 ${cur_context} Get Current Context log ${cur_context} ${page} Log Source log ${page} Page Should Contain Text 美妆 Click Element xpath=//*[@id="J_5132393350"]/div/div/div/a[2] sleep 10 [Teardown] Close All Applications *** Keywords ***
使用Switch To Context切换到对应webview后,继续使用appium关键字操作webview中的元素