我想验证表格内颜色编码背景的特定值。颜色代码是background-color:rgb(96,192,96)。我在页面上有5个不同的链接。每个链接都有相同的背景颜色。我需要验证每个链接的背景颜色是否显示为 rgb(96,192,96)。如果颜色代码不是 rgb(96,192,96),则代码应认为链接/服务器已关闭。
页面上显示的五个值/链接是 Ssi-1-a、Ssi-2-a、Ssi-3-a、Ssi-4-a 和 Ssi-5-a
如何使用 Xpath 或任何其他方法验证这一点?提供以下代码
<html>
<head>
<body>
<b>Status as of </b>
Wed Oct 25 16:57:57 2017
<br/>
<br/>
This page shows the current version and build date of the SSI code loaded into the JVMs that constitute the environment
you selected.
<br/>
<br/>
<br/>
<div style="float:left">
<table style="display:inline-table" width="500" border="1">
<tbody>
<tr>
<tr>
<tr>
<th>Prod</th>
<td style="background-color:rgb(96,192,96)" align="center">
<a href="https://XXXXXXXXXXXXXX-XXX.net:XXXXXX/ssiadmin/">Ssi-1-a</a>
</td>
</tr>
<tr>
<tr>
<tr>
<tr>
</tbody>
</table>
</div>
</body>
</html>
最佳答案
driver.findElement(By.name("nameOfComponent")).getCssValue("background-color");
关于java - 如何使用 Selenium Web Driver/Java 验证表格中的颜色编码背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47018176/