Appium :只有一个NATIVE_APP,跳转页面后提示:NoSuchElementException: Message: An element could not be locate..

异常:

NoSuchElementException: Message: An element could not be located on the page using the given search parameters.

在这里插入图片描述

这几天用appium写自动化,遇到一个问题,就是在A页面点击一个按钮进入B页面,B页面的元素怎么都获取不到。纠结了几天,在网上找了很多方法也没能解决,后来在官方文档看到:

The UiAutomator2 Driver for Android

Appium’s flagship support for automating Android apps is via the UiAutomator2 driver. (New to Appium? Read our introduction to Appium drivers). This driver leverages Google’s UiAutomator2 technology to facilitate automation on a device or emulator.

Development of the UiAutomator2 driver happens at the appium-uiautomator2-driver repo.

Older Android-based drivers include:
The UiAutomator Driver
The Selendroid Driver

Usage
The way to start a session using the UiAutomator2 driver is to include the automationName capability in your new session request, with the value UiAutomator2. Of course, you must also include appropriate platformName (=Android), platformVersion, deviceName, and app capabilities, at a minimum.

It is highly recommended to also set the appPackage and appActivity capabilities in order to let Appium know exactly which package and activity should be launched for your application. Otherwise, Appium will try to determine these automatically from your app manifest.

突然灵感一现,在启动app的参数配置中加上UiAutomator2 设置,是不是就可以了呢,结果加上后就真的好了,喜极而泣。方法如下:

                'platformName': 'Android',
                'platformVersion': platformVersion,
                'deviceName': deviceName,
                'automationName': 'uiautomator2',
                'newCommandTimeout': 240,
                "udid": XXXXX,
                "appActivity": appActivity,
                "appPackage": appPackage

希望对大家有帮助能解决你的问题。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值