如何使用webdriver中的css选择器按值定位元素? [英] how to locate an element by value using css selector in webdriver?

查看:411
本文介绍了如何使用webdriver中的css选择器按值定位元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于下列元素,如何使用css选择器通过td的值找到它?在这种情况下,它是唯一文本

 < td class =someclasscolspan =3> 
唯一文本
< / td>


解决方案



使用CSS选择器,

  By.cssSelector(td [class = '] [value ='unique text']); 

有关使用css选择器的更多信息,查看此处


For the following element, how to find it by the value of the td using css selector? In this case it's "unique text"

<td class="someclass" colspan="3">
   unique text
</td>

解决方案

You could use something like this,

With CSS Selector,

 By.cssSelector("td[class='someclass'][value='unique text']");

For more information on using css selector, See here

这篇关于如何使用webdriver中的css选择器按值定位元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆