小编典典

如何使用Selenium获取CSS类名称?

selenium

我是selenium测试的新手。我想使用selenium获取css类名。我正在使用eclipse和Java进行开发。

<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”?一世


阅读 888

收藏
2020-06-26

共1个答案

小编典典

是的,您可以根据需要使用getAttribute(attributeLocator)功能。

 selenium.getAttribute(//xpath@class);

指定需要知道其类的元素的Xpath。

谢谢。

2020-06-26