如何获取css类名使用Selenium? [英] How to get css class name using Selenium?
本文介绍了如何获取css类名使用Selenium?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是新的硒测试。我想使用selenium获得css类名。我使用eclipse和Java进行开发。
I am new in selenium testing. I want to get the css class name using selenium. I am using eclipse and Java for development.
<table >
<tr class="odd"><td>Odd row</td></tr>
<tr class="even"><td>Even row</td></tr>
<tr class="odd"><td>Odd row2</td></tr>
<tr class="even"><td>Even row2</td></tr>
</table>
有没有办法使用selenium获得类名'odd'或'even' I
Is there any way to get the class name 'odd' or 'even' using selenium? I
推荐答案
是的,您可以使用 getAttribute(attributeLocator)
您的需求。
Yes, you can use getAttribute(attributeLocator)
function for the your requirement.
selenium.getAttribute(//xpath@class);
指定您需要知道其类别的元素的Xpath。
Specify the Xpath of the element for which you require to know the class of.
感谢。
这篇关于如何获取css类名使用Selenium?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文