public class JsEvent extends AbstractEvent
文件名:JsEvent.java
用途:用提供通过Javascript来修改或者获取页面元素内容的方法
编码时间:2018年12月2日 下午12:51:19
修改时间:2020年10月18日 下午3:52:44
brower, exceptionSet, isLocationElement, LOCATION_ELEMENT_JS, wait, waitTime, webElement
Constructor and Description |
---|
JsEvent(AbstractBrower brower)
构造对象
|
Modifier and Type | Method and Description |
---|---|
String |
addElement(Element element,
String elementName)
在指定的元素下方添加一个元素,元素将带一个名为temp_attribute的属性,其属性的值为一个uuid,并且添加成功后
方法返回该元素定位xpath,格式为“//标签名[@temp_attribute='uuid']”
|
com.alibaba.fastjson.JSONObject |
deleteElement(Element element)
删除指定的元素,并以json的格式返回被删除的元素信息,其形式为:
|
String |
getAttribute(Element element,
String attributeName)
获取元素的指定的属性值,若属性不存在时,则返回空串。
|
String |
putAttribute(Element element,
String attributeName,
String value)
设置元素的属性值,并返回属性的原值,若设置的属性名不存在时,则在该元素上增加相应的属性
|
Object |
runScript(String script,
Object... args)
用于执行已经写好的js脚本
|
actionOperate, arrayToString, getBrower, getExceptionInfomation, isExistElement, locationElement, setLocationElement, setWaitTime
public JsEvent(AbstractBrower brower)
brower
- 浏览器AbstractBrower
类对象public String getAttribute(Element element, String attributeName)
element
- Element
对象attributeName
- 属性名org.openqa.selenium.TimeoutException
- 元素无法操作时抛出的异常org.openqa.selenium.NoSuchElementException
- 元素不存在或下标不正确时抛出的异常public String putAttribute(Element element, String attributeName, String value)
element
- Element
对象attributeName
- 需要设置的属性名value
- 需要设置的属性值org.openqa.selenium.TimeoutException
- 元素无法操作时抛出的异常org.openqa.selenium.NoSuchElementException
- 元素不存在或下标不正确时抛出的异常public String addElement(Element element, String elementName)
element
- Element
对象elementName
- 新元素(标签)的名称org.openqa.selenium.TimeoutException
- 元素无法操作时抛出的异常org.openqa.selenium.NoSuchElementException
- 元素不存在或下标不正确时抛出的异常public com.alibaba.fastjson.JSONObject deleteElement(Element element)
{ "tagname":元素标签名称 "attributes":[ { "name":属性1名称 "value":属性1值 }, { "name":属性1名称 "value":属性1值 }, ... ] }
element
- Element
对象org.openqa.selenium.TimeoutException
- 元素无法操作时抛出的异常Copyright © 2024. All rights reserved.