html - css list-style-type decimal,编号自动化测试
问题描述
我有一个基于 js 和 css 的 pproject。我有一种情况,我将编号列表如下
- 咖啡
- 茶
- 可乐
我正在通过
<!DOCTYPE html>
<html>
<head>
<style>
ul.a {list-style-type: decimal;}
</style>
</head>
<body>
<h1>The list-style-type Property</h1>
<p>Example of unordered lists:</p>
<ul class="a">
<li>Coffee</li>
<li>Tea</li>
<li>Cola</li>
</ul>
</body>
</html>
一切正常。但是现在的问题是,当我们通过自动化进行测试时,我们想检查列表是否有编号。但是由于列表是通过 css 控制的,所以它不会出现在 DOM 中。
有什么方法可以测试它。请帮忙
解决方案
您可以使用getCssValue()
selenium 中的方法来检索 css 属性。在你的情况下尝试
public boolean isListStyleTypeNumber() {
return driver.findElement(By.cssSelector("ul.a")).getCssValue("list-style-type").equals("decimal") ? true : false;
}
推荐阅读
- php - 如何在实时服务器上使用 sudo 运行 php exec
- matlab - 在 matlab 中使用 disp_function 显示斐波那契数列
- ruby-on-rails - 某些变体的 Rails ActiveStorage 变体 IntegrityError 但未修改的图像始终显示
- msmq - MSMQ 事务性或可恢复
- c# - 我们如何将 XML 作为请求传递给 .Net 核心 API,并从 C# 中的相同 API 获取 XML 响应?
- jenkins - Jenkins 管道代理使用环境变量
- ios - 如何向具有 yelp api 数据的表视图添加搜索功能?
- django - Django模板:如何传递格式化字符串以包含标签
- jpa - JPARepository - 有时会创建重复记录
- git - 如何撤消 git 丢弃