public class TextEvent extends AbstractEvent
文件名:TextEvent.java
用途:定义了对控件文本操作相关的方法,可通过该类,对页面进行对控件输入,文本获取等操作
编码时间:2019年9月6日上午9:28:59
修改时间:2021年10月18日 上午11:37:14
brower, exceptionSet, isLocationElement, LOCATION_ELEMENT_JS, wait, waitTime, webElement
Constructor and Description |
---|
TextEvent(AbstractBrower brower)
构造对象
|
Modifier and Type | Method and Description |
---|---|
String |
clear(Element element)
该方法通过控件名称或定位方式对页面元素进行定位来清空控件中的内容,主要用于清空文本框中已有的数据。该方法将存储被清空的 文本
|
String |
getAttributeValue(Element element,
String attributeName)
用于获取元素中的指定属性值的内容
|
String |
getImageText(Element element)
用于对“数字+英文”类型的图片内容进行识别的方法,根据图片元素位置,识别图片中的内容。
注意,该方法识别成功的概率不高,在“数字+英文”的模式下,经常将数字识别为英文。
|
String |
getText(Element element)
用于获取相应元素中的文本内容
|
String |
input(Element element,
String text)
用于在指定的控件中输入相应的内容
|
String |
keyToSend(Element element,
KeyType... keyTypes)
用于向页面上发送键盘按键
|
String |
updataFile(Element element,
File updataFile)
用于向控件中上传指定的文件。
|
actionOperate, arrayToString, getBrower, getExceptionInfomation, isExistElement, locationElement, setLocationElement, setWaitTime
public TextEvent(AbstractBrower brower)
brower
- 浏览器AbstractBrower
类对象public String clear(Element element)
element
- Element
对象org.openqa.selenium.TimeoutException
- 元素无法操作时抛出的异常org.openqa.selenium.NoSuchElementException
- 元素不存在或下标不正确时抛出的异常public String getAttributeValue(Element element, String attributeName)
element
- Element
对象attributeName
- 属性名称org.openqa.selenium.TimeoutException
- 元素无法操作时抛出的异常org.openqa.selenium.NoSuchElementException
- 元素不存在或下标不正确时抛出的异常public String getText(Element element)
element
- Element
对象org.openqa.selenium.TimeoutException
- 元素无法操作时抛出的异常org.openqa.selenium.NoSuchElementException
- 元素不存在或下标不正确时抛出的异常public String input(Element element, String text)
element
- Element
对象text
- 需要输入到控件中的内容org.openqa.selenium.TimeoutException
- 元素无法操作时抛出的异常org.openqa.selenium.NoSuchElementException
- 元素不存在或下标不正确时抛出的异常public String getImageText(Element element)
element
- 图片元素Copyright © 2024. All rights reserved.