Selenide框架方法SelenideElement.java文件解析

本文详细解析SelenideElement框架中的关键方法,包括setValue、val、append等输入操作,以及getText、getOwnText、innerHtml等属性获取。此外,还涵盖交互操作如pressEnter、isDisplayed,以及条件判断如should和shouldNot系列方法,帮助理解SelenideElement在自动化测试中的应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

SelenideElement.java

setValue

SelenideElement setValue(string): 输入字符串

val

SelenideElement val():
t要附加到文本字段中的任何文本。

String val()
Get the “value” attribute of the element
Returns: attribute “value” value or null if attribute is missing
获取元素的“value”属性
返回: 属性“value”值,如果缺少属性,则为null

append

SelenideElement append(String text); 可追加value

pressEnter/pressTab/pressEscape
getText()

Get the text of the element WITHOUT children.

getOwnText() /innetTest()可以获取隐藏元素文本

Get the text code of the element with children.
It can be used to get the text of a hidden element.

innerHtml

Get the attribute of the element. Synonym for getAttribute(String)

String attr(String attributeName);

attribute “name” value or null if attribute is missing

String pseudo(String pseudoElementName, String propertyName) 伪元素属性

Get content of the pseudo-element
Params:
pseudoElementName – pseudo-element name of the element, “:before”, “:after”
Returns:
the content value or “none” if the content is missing

String pseudo(String pseudoElementName)/selectRadio radio 按钮属性

Select radio button
Params:
value – value of radio button to select
Returns:
selected “input type=radio” element

data(String dataAttributeName)

获取属性信息

getAttribute(String name)/getCssValue(String propertyName);

Get the value of a given CSS property;

exists()/isDisplayed()

exisits() : Check if this element exists and visible.
isDisplayed: 没有等待时间

is(Condition Condition)

如果元素与给定条件匹配,则立即返回true。方法不等待!警告:此方法有助于实现crooks,但对于典型的ui测试不需要此方法。

has/
SelenideElement setSelected(boolean selected)

Checks that given element meets all of given conditions.

should/shouldHave/shouldBe

返回element元素 有默认等待时间,可以加等待时间;
可以多条件同时使用;
$("#errorMessage").should(exist);

shouldNot/shouldNotHave/shouldNotBe
waitUntil

可以自定义等待时间

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值