zoukankan      html  css  js  c++  java
  • 模糊定位

    #div,span的定位

    只能通过A,B区分

    <div id="tab-first" class="el-tabs__item is-active" aria-controls="pane-first" role="tab" aria-selected="true" tabindex="0">A</div>
    <div id="tab-first" class="el-tabs__item is-active" aria-controls="pane-first" role="tab" aria-selected="true" tabindex="0">B</div>

    By.xpath("//div[text()="A"]")).click();//点击A(如果是span,就把div改为span)

    # 通过文本内容精准定位元素。可能由于页面内容有空格,经常定位不到元素

    driver.find_element_by_xpath(‘//div[text()="活动服务"]‘) # 若要定位其它标签元素(如:td,span等),只需要替换div即可

    # 通过文本内容模糊定位元素

    driver.find_element_by_xpath(‘//div[contains(text(),"活动服务")]‘)

    find_element_by_xpath('//*[text90="保存"]')

     <input id="su" class="bg s_btn btnhover" value="百度一下" type="submit"/> //*[@id='su'] 获取id 的属性为'su' 的值

    //input[contains(@class,'bg s_btn')]

    # 通过属性模糊定位元素

    <a class="lb" href="https://passport.baidu.com/v2/?login&tpl=mn&u=http%3A%2F%2Fwww.baidu.com%2F" name="tj_login" onclick="return false;">登录</a>
    //a[starts-with(@name,'tj_lo')]     属性模糊定位
    //a[contains(@name,'tj_lo')] 属性模糊定位
  • 相关阅读:
    解决Cannot change version of project facet Dynamic web module to 3.0
    mysql 存储过程
    查看建表语句
    mysql query cache 查询缓存
    数据库连接池
    JDBC Statement PrepareStatement
    mysql 改变表结构 alter
    maven 获取pom.xml的依赖---即仓库搜索服务
    windows常用快捷键
    oracle 的数据完整性
  • 原文地址:https://www.cnblogs.com/xl95/p/12734987.html
Copyright © 2011-2022 走看看