public abstract class FindMultiElement<T extends FindMultiElement<T>> extends FindElement
文件名:ListBy.java
用途: 提供对多元素获取与返回的基本方法
编码时间:2020年10月14日下午6:54:46
修改时间:2020年10月14日下午6:54:46
Modifier and Type | Field and Description |
---|---|
protected boolean |
firstEmpty
用于记录当前元素集合中第一个元素是否为不可选择的元素,用于对元素的随机返回
|
action, brower, elementData, elementList, isAutoSwitchIframe, read
Constructor and Description |
---|
FindMultiElement(AbstractBrower brower)
构造方法,初始化浏览器对象
|
Modifier and Type | Method and Description |
---|---|
T |
find(String elementName,
String... linkKeys)
用于指定查找的元素集合名称,二次查找元素时,将覆盖上一次查找的元素。调用该方法在
无法查到页面元素时,其不会抛出
TimeoutException 异常 |
List<Element> |
getAllElement()
用于返回当前元素集合中所有的元素集合。若未调用
find(String, String...) 方法对元素进行查找,
或者查无元素时,则调用该方法时会抛出超时异常 |
Element |
getElement(int index)
用于获取元素集合中指定下标的元素,该下标允许反向遍历与随机返回,其下标所传入的数字即为元素所在的真实下标。
|
boolean |
removeElement(int index)
用于移除元素集合中的指定下标的元素。其下标所传入的数字即为元素所在的真实下标,可参见
getElement(int) 方法的参数说明。若未调用find(String, String...)
方法对元素进行查找,或者查无元素时,调用该方法将不进行任何操作 |
void |
setFirstIsEmpty(boolean firstEmpty)
用于设置当前元素集合中首元素是否为允许随机返回的元素
例如:获取列表元素时,首元素为标题元素;获取下拉选项元素集合时, 第一个元素为空选项或者为类似“请选择”等选项 |
int |
size()
用于返回当前存储的元素集合长度,若未对元素进行获取,则返回0
|
autoSwitchContext, autoSwitchFrame, clearAction, findElement, getBy, getElementData, recognitionElement, setAction, setAutoSwitchIframe, setReadMode, setWaitTime, switchAppNativeContext, switchFrame, switchParentFrame, switchRootFrame, switchWebViewContext, toElementIndex
public FindMultiElement(AbstractBrower brower)
brower
- AbstractBrower
类对象public void setFirstIsEmpty(boolean firstEmpty)
firstEmpty
- 首元素是否为允许随机返回的元素public T find(String elementName, String... linkKeys)
TimeoutException
异常elementName
- 元素名称linkKeys
- 外链词语public int size()
public boolean removeElement(int index)
getElement(int)
方法的参数说明。若未调用find(String, String...)
方法对元素进行查找,或者查无元素时,调用该方法将不进行任何操作index
- 元素下标public Element getElement(int index)
用于获取元素集合中指定下标的元素,该下标允许反向遍历与随机返回,其下标所传入的数字即为元素所在的真实下标。
例如:
注意:调用该方法前,若未调用find(String, String...)
方法对元素进行查找,
或者查无元素时,调用该方法不会抛出异常,但当调用Element.getWebElement()
方法时,
由于未查到元素则会抛出异常
index
- 元素下标Element
类对象public List<Element> getAllElement()
find(String, String...)
方法对元素进行查找,
或者查无元素时,则调用该方法时会抛出超时异常Copyright © 2024. All rights reserved.