java - 如何使用 Selenium 和 Java 验证搜索结果中的所有单词以特定字母开头
问题描述
我在搜索字段中输入“A”并回车。我有一份员工名单。我需要验证搜索结果中所有以字母“A”开头的员工姓名。
解决方案
一个示例,您只需找到找到的所有员工姓名:
WebElement[] employees = driver.findElements(By. ...)
for (WebElement employee: employees) {
if (!employee == null && employee.getText().substring(0, 1).toLowerCase().equals("a") {
System.out.print(employee + " begins with 'a'")
}
else {
System.out.print(employee + " does not begin with 'a'")
}
}
我不知道源页面。也许可以通过以下方式(也)挖掘员工姓名:
employee.getAttribute("value")
推荐阅读
- assembly - 我应该如何在程序集 8086 中命名我的标签
- python - 如何通过 ManyToManyField 检索 django 模板中的 .count
- reactjs - React Native 在 https 请求上从 REST api 获取数据错误
- c# - 使用 InMemoryDatabase 返回计数为 0 的 NUnit 测试
- angular - 如何使用 Angular 路由器模块在 Ionic 5 中显示选项卡
- android - 分支 IO 深层链接自定义别名不起作用。相同的链接不在两个不同的应用程序中共享?
- zfs - 物理端口移动后 ZFS 路径不匹配
- html - 如何在拖放角度中制作一个空的输入文本框
- c - *(long *) 和 *(int*) 是什么意思?
- node.js - 在 React Native 和 NodeJS 后端使用 Google 登录