public class AssertStringUtil extends Object
文件名:ContentAssertUtil.java
用途: 提供对文本内容进行判断的工具
编码时间:2021年6月24日上午8:05:14
修改时间:2021年6月24日上午8:05:14
| Constructor and Description |
|---|
AssertStringUtil() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
assertNumber(String text,
CompareNumberType compareNumberType,
double compareNumber)
断言元素中的数字内容与指定的数字按照
CompareNumberType指定的比较类型进行比较。若断言的
元素文本内容为非数字字符时,则返回false |
static boolean |
assertTextContainKey(String text,
boolean isJudgeAllKey,
String... keys)
断言文本内容中包含指定的关键词。可设置文本内容是否需要判断传入的所有关键词,即
当需要完全判断时,则当且仅当文本包含所有关键词时,断言方法返回true
当不需要完全判断时,则当前仅当文本不包含所有关键词时,断言方法返回false
|
static boolean |
assertTextNotContainKey(String text,
boolean isJudgeAllKey,
String... keys)
断言文本内容中不包含指定的关键词。可设置文本内容是否需要判断传入的所有关键词,即
当需要完全判断时,则当且仅当文本不包含所有关键词时,断言方法返回true
当不需要完全判断时,则当前仅当文本包含所有关键词时,断言方法返回false
|
public static boolean assertTextContainKey(String text, boolean isJudgeAllKey, String... keys)
断言文本内容中包含指定的关键词。可设置文本内容是否需要判断传入的所有关键词,即
例如,假设元素中存在文本“你好,世界!”,则
注意:若不传入关键词,或关键词为null时,则返回true
text - 需要断言的文本isJudgeAllKey - 是否需要完全判断所有关键词keys - 关键词组org.openqa.selenium.TimeoutException - 元素无法操作时抛出的异常org.openqa.selenium.NoSuchElementException - 元素不存在或下标不正确时抛出的异常public static boolean assertTextNotContainKey(String text, boolean isJudgeAllKey, String... keys)
断言文本内容中不包含指定的关键词。可设置文本内容是否需要判断传入的所有关键词,即
例如,假设元素中存在文本“你好,世界!”,则
注意:若不传入关键词,或关键词为null时,则返回true
text - 需要断言的文本isJudgeAllKey - 是否需要完全判断所有关键词keys - 关键词组org.openqa.selenium.TimeoutException - 元素无法操作时抛出的异常org.openqa.selenium.NoSuchElementException - 元素不存在或下标不正确时抛出的异常public static boolean assertNumber(String text, CompareNumberType compareNumberType, double compareNumber)
CompareNumberType指定的比较类型进行比较。若断言的
元素文本内容为非数字字符时,则返回falsetext - 文本内容compareNumberType - 比较方式CompareNumberType枚举类compareNumber - 预期数字Copyright © 2024. All rights reserved.