zoukankan      html  css  js  c++  java
  • selenium之如何使用cssSelector定位页面元素

    一.概述

    cssSelector也是一种常用的选择器,CSS locator比XPath locator速度快,用CSS Selector能非常精准的定位到想测试的Elements

    二.cssSelector常用符号说明

    # 表示id

    . 表示class

    > 表示子元素,层级

    一个空格也表示一个子元素,但是所有的子元素相当于xpath中的相对路径

    三.cssSelector的常用用法

    #input 选择id为input的节点

    .Volvo 选择class为Volvo的节点

    div#radio>input 选择id为radio的div下的所有的input节点

    div#radio input 选择id为radio的div下的所有的子孙后代input节点

    div#radio>input:nth-of-type(4) 选择id为radio的div下的第4个input节点

    div#radio>nth-child(1) 选择id为radio的div下的第1个子节点

    div#radio>input:nth-of-type(4)+label 选择id为radio的div下的第4个input节点之后挨着的label节点

    div#radio>input:nth-of-type(4)~labe 选择id为radio的div下的第4个input节点之后的所有label节点

    input.Vovlo[name='identity'] 选择class为.Volvo并且name为identity的input节点

    input[name='identity'][type='radio']:nth-of-type(1) 选择name为identity且type为radio的第1个input节点

    input[name^='ident'] 选择以ident开头的name属性的所有input节点

    input[name$='entity'] 选择以'entity'结尾的name属性的所有input节点

    input[name*='enti'] 选择包含'enti'的name属性的所有input节点

    div#radio>*.not(input) 选择id为radio的div的子节点中不为input的所有子节点

    input:not([type='radio']) 选择input节点中type不为radio的所有节点

  • 相关阅读:
    C#中的abstract、virtual、interface关键字
    tsql字符串截取
    C# byte换算
    apple-mobile-web-app-capable
    Content-Security-Policy
    sqlserver建立连接服务器
    20 ViewPager Demo4自动轮播
    20 ViewPager Demo3指示器
    20ViewPager demo1,2:接收ViewPager展示View的使用
    有没有最好的学习Angularjs2的视频入门体验?
  • 原文地址:https://www.cnblogs.com/liwu/p/5016716.html
Copyright © 2011-2022 走看看