如何验证页面上的某个css元素是否为具有selenium的特定图像

时间:2010-09-25 20:11:34

标签: selenium selenium-ide automated-tests

我有一个页面,我想用selenium检查,它使用一个元素的特定背景图像。我想确保此图像仍然存在于连接到该元素的页面上。我怎么用硒做这个。如果这改变了我正在使用browsermob.com进行测试,一旦我通过selenium ide运行它。

1 个答案:

答案 0 :(得分:1)

除了almos重复问题上的建议事项之外...你可以检查你的body元素的属性是否设置为图像。

如果getAttribute返回有效值。喜欢:

new Wait()
    {

        public boolean until()
        {
            return selenium.getAttribute("ElementLocator")
                + "@class").equals("active");
        }
    }.wait("The menu item did not get active.",
        defaultTimeOutValue);

这将等待@class属性的值为“active”。

或者在确定页面已加载后,只需使用If语句。

希望这有帮助, 干杯, 盖尔盖伊。

相关问题