public class DimEvent extends AbstractEvent
文件名:DimEvent.java
用途: 简化事件写法的模糊事件,根据元素的类型和默认值,自动关联元素的点击和输入事件,以简化事件的编写。
在类中,定义了获取元素文本内容的关键词“get”和清空文本的关键词“clear”,当元素的默认值为该字符串时, 则将方法定义为获取元素的文本内容,故在编写元素默认值时,需要注意该关键词,避免造成不符合预期的结果。
编码时间:2021年3月23日下午6:29:22
修改时间:2021年3月23日下午6:29:22
Modifier and Type | Field and Description |
---|---|
static String |
CONST_CLEAR_VALUE
用于指定获取元素文本内容的字符串
|
static String |
CONST_GET_TEXT_VALUE
用于指定获取元素文本内容的字符串
|
brower, exceptionSet, isLocationElement, LOCATION_ELEMENT_JS, wait, waitTime, webElement
Constructor and Description |
---|
DimEvent(AbstractBrower brower)
构造对象
|
Modifier and Type | Method and Description |
---|---|
void |
addFunction(DataDriverFunction function)
用于添加自定义的公式到类中,应用于对公式型的默认值进行转译
|
String |
event(Element... elements)
用于根据传入的元素,自动选择相应的事件,并进行操作,返回操作结果
|
ArrayList<String> |
getResultList()
用于返回上一次调用模糊事件后的执行结果集合
|
actionOperate, arrayToString, getBrower, getExceptionInfomation, isExistElement, locationElement, setLocationElement, setWaitTime
public static final String CONST_GET_TEXT_VALUE
public static final String CONST_CLEAR_VALUE
public DimEvent(AbstractBrower brower)
brower
- 浏览器AbstractBrower
类对象public void addFunction(DataDriverFunction function)
方法支持传入正则表达式,当默认值满足传入的正则时,则会将其按照在公式中定义 的处理方式对数据进行处理,生成对应的数据。例如:
当元素默认值为“${World}”时,其字符串“World”与正则表达式“Wo.*”匹配,故在事件的操作中,该字符串将被解析为“Hello World!”
addFunction(new DataDriverFunction("Wo.*", text -> "Hello " + text + "!"));
注意:
String
类型Functions
类中已定义多个默认公式可供选择,其方法均为静态方法,返回值为DataDriverFunction
function
- 方法public String event(Element... elements)
注意:
elements
- 元素组Copyright © 2024. All rights reserved.