myi想知道是否可以使用Selenium IDE检查来自外部CSS文件的值?
我的HTML:
<div id="myBlock">
我的css风格:
#myBlock {
background: none repeat scroll 0 0 #ffffff;
margin: 0;
padding: 0;
}
我需要验证背景颜色。我尝试将verifyAttribute与// [@ id =“myBlock”] @ background或// [@ id =“myBlock”] @ style一起使用,但未找到该属性。这样做的正确方法是什么?
答案 0 :(得分:0)
storeEval和JavaScript的getComputedStyle的组合在过去已成功运作。当然,您必须在浏览器中启用JavaScript!
下面,当在Selenium IDE中针对您的HTML运行时,应该返回HEX代码的RGB代码。
<tr>
<td>storeEval</td>
<td>window.document.defaultView.getComputedStyle(window.document.getElementsByClassName('myBlock')[0]).getPropertyValue('background-color')</td>
<td>StoredColorVariable</td>
</tr>
变量StoredColorVariable
现在将包含背景颜色rgb(255,255,255)。