我正在开发一个使用空手道和 appium 自动化移动应用程序的项目。我正在开发的应用程序似乎是一个混合应用程序。当我启动应用程序时,它会将我重定向到要登录的 Web URL(Web 浏览器),并且我的空手道测试无法找到登录页面下存在的元素。
Feature: android test
Background: App Preset
* configure driver = { type: 'android', webDriverUrl : 'xxxxx', start: false, httpConfig : { readTimeout: 120000 } }
Scenario: android mobile app UI tests
Given driver { webDriverSession: { desiredCapabilities : "#(android.desiredConfig)"} }
And driver.click('//android.widget.Button[@text="Get Started"]')
# Sign details
And click('#signInName')
And input('#signInName', '[email protected]')
And input('#password', '123456')
默认情况下,空手道会让您处于本机应用程序上下文中。您可以通过调用移动命令来检查所有可用的上下文,
def contexts = driver.script("mobile: getContexts")
or
json contexts = driver.http.path("contexts").get()
and print contexts
您应该能够将上下文切换到网络视图,如下所示(而不是WEBVIEW_1
使用您从上一步获得的相应网络视图),
driver.setContext("WEBVIEW_1")
然后切换回本机应用程序
driver.setContext("NATIVE_APP")
如果遇到任何问题,请尝试不同的定位器策略
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)