appium通过同级别(兄弟关系)元素找到元素

在做appium测试用例的时候,要获取金额值,用uiautomatorviewer查看该元素,该元素没有特别明显的个性特点,唯一有特点的定位是有content-desc值,但是该值是变动的,所以无法通该元素自身特点来找到该元素。元素如下图:

既然无法通过自身查找元素,发现也无法通过上一级元素定位,后面发现底部的按钮“我的资产(元)”算是这个页面比较有特殊的,并且肯定能定位到的,再查看“我的资产(元)”元素和金额元素是同一个级别的,这样就能通过xpath的兄弟关系找到金额元素,关系如下:

怎样通过兄弟关系找到元素呢,查找xpath语法资料,Element <E1> preceding some sibling <E2> 可以满足需求

依照xpaht语法要求,//E2/preceding-sibling::E1,先找到e2再找e1 定位的是e1

e2定位的是:"//android.view.View[@content-desc=‘我的资产(元)‘]

因为e2 前面只有e1 ,所有定位e1就只要用android.view.View就可以了,最后,能准确找到金额定位方式为:

//android.view.View[@content-desc=‘我的资产(元)‘]/preceding-sibling::android.view.View

原文地址:https://www.cnblogs.com/testway/p/9319080.html

时间: 2024-08-30 18:17:41

appium通过同级别(兄弟关系)元素找到元素的相关文章

通配符的匹配很全面, 但无法找到元素 &#39;tx:annotation-driven&#39;

配置Spring时出现如题这个错误,下面是xml的内容 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http:/

通配符的匹配很全面, 但无法找到元素 &#39;context:property-placeholder&#39; 的声明。

在Spring相应包导入正确的前提下,出现这个异常,是因为我们在引入命名空间的时候,没有正确引入它的DTD解析文件,以上面的context为例,解决办法如下: 在引入 xmlns:context="http://www.springframework.org/schema/context"的同时,在xsi:schemaLocation这个字符串中添加context相关的解析文件:http://www.springframework.org/schema/context http://w

Selenium Web 自动化 - 如何找到元素

Selenium Web 自动化 - 如何找到元素 2016-07-29 1. 什么是元素? 元素:http://www.w3school.com.cn/html/html_elements.asp 2. 定位方式解析 Selenium WebDriver 提供一个先进的技术来定位 web 页面元素.Selenium 功能丰富的API 提供了多个定位策略如:Name.ID.CSS 选择器.XPath 等等,如下图所示: 一般会用ID来定位,因为它是唯一的,xpath也比较通用,火狐浏览器插件:f

SSM商城系统开发笔记-问题01-通配符的匹配很全面, 但无法找到元素 &#39;mvc:annotation-driven&#39; 的声明。

配置搭建完后进行Post请求测试时报错: Caused by: org.xml.sax.SAXParseException; lineNumber: 14; columnNumber: 29; cvc-complex-type.2.4.c: 通配符的匹配很全面, 但无法找到元素 'mvc:annotation-driven' 的声明. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseExce

webdriver中定位元素,报无法找到元素的问题

webdriver中定位元素,报无法找到元素的问题时,需要查看以下几点: 1 用火狐的firebug插件定位元素,确保这个元素的定位正确: 2 在火狐的firebug插件的,在html页签中输入frame或者iframe去查看这个元素所在的frame或iframe是什么: 写如下语句: WebElement iframe = driver.findElement(By    .xpath("//*[@id='ContentFrame']"));  driver.switchTo().f

找到元素路径

1: 通过chrome浏览器找到元素的xpath 或者css路径.chrome->左键页面元素->审查元素->左键HTML元素->copy css或者xpath地址2: 通过chrome F12 console检测xpath地址或者css地址是否返回正确元素xpath使用 $x("xpath") css使用$("css")

springMVC:通配符的匹配很全面, 但无法找到元素 &#39;mvc:annotation-driven&#39; 的声明

转自:http://blog.csdn.net/tolcf/article/details/50845483 报错信息:通配符的匹配很全面, 但无法找到元素 'mvc:annotation-driven' 的声明 原因是:虽然在xml文件上方声明了mvc,但没有配置此声明对应的文件信息,正确配置如下: <beans xmlns="http://www.springframework.org/schema/beans"       xmlns:xsi="http://ww

关于spring”通配符的匹配很全面, 但无法找到元素 &#39;context:component-scan&#39; 的声明“的错误

关于spring配置的问题 近日学习spring时遇到了这个问题: [html] view plain copy org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 12 in XML document from URL [file:/F: /workspace/spring/target/classes /applicationContext.xml] is invalid; nested ex

通配符的匹配很全面, 但无法找到元素

关于spring配置的问题 近日学习spring时遇到了这个问题: [html] view plain copy org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 12 in XML document from URL [file:/F: /workspace/spring/target/classes /applicationContext.xml] is invalid; nested ex