硒访问CSS类属性 [英] access css class properties in selenium
本文介绍了硒访问CSS类属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个HTML < DIV>
元素,并希望检查其是否使用左侧硒对齐。然而,浮动:左
CSS属性是在CSS类中定义
I have a HTML <div>
element and wish to check if it is left aligned using Selenium. However the float:left
CSS property is defined in a CSS class.
有没有我可以访问CSS类通过硒属性什么办法?或者是否有任何其他方式来获得这个值?
Is there any way in which I can access the CSS class attributes through Selenium? Alternately is there any other way to get this value?
<div class="myclass">
...
</div>
在sample.css
In sample.css
.myclass{
float:left;
}
我试图用 getEval()
- this.page()findElement(富)
找出一个办法让CSS类属性。
I was trying to use getEval()
- this.page().findElement("foo")
to find out a way to get CSS class attributes.
推荐答案
使用的webdriver您可以使用CSS selektors:
With webdriver you can use css selektors:
WebElement element = driver.findElement(By.cssSelector(".myclass"));
String float = element.getCssValue("float");
更新的答复!
这篇关于硒访问CSS类属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文