码迷,mamicode.com
首页 > Web开发 > 详细

Xpath 与Css 定位方式的比较

时间:2017-07-06 20:37:22      阅读:232      评论:0      收藏:0      [点我收藏+]

标签:text   需要   bsp   span   pat   一个   方式   log   执行   

1. 执行速度Css更快

2. 对于文本的处理xpath更强大使用

String locator_Xpath = "//*[contains(text(),‘test‘)]";

 

 3. 使用祖先元素属性与当前元素属性组合处理时,CSS不需要严格写出层次结构

<div class="111">
    <div>
        <div>
            <input class = "222"/>
        </div>
    </div>
    
</div>

String locator_xpath="//div[@class=‘111‘/*/*/*[@class=‘222‘]]";
String locator_css = ".111 .222";    

 *注意两个class之前有一个空格表示层级关系

Xpath 与Css 定位方式的比较

标签:text   需要   bsp   span   pat   一个   方式   log   执行   

原文地址:http://www.cnblogs.com/tina-cherish/p/7127812.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!