zoukankan      html  css  js  c++  java
  • Selenium+python---xpath定位

     by  yoyo

     # coding:utf-8

    from selenium import webdriver
    driver = webdriver.Firefox()
    driver.get("http://www.baidu.com")
    # use xpath by id
    driver.find_element_by_xpath("//*[@id='kw']").send_keys("python")
    # use xpath by name
    driver.find_element_by_xpath("//*[@name='wd']").send_keys("python")
    # use xpath by class
    driver.find_element_by_xpath("//*[@class='s_ipt']").send_keys("python")
    # use xpath by other
    driver.find_element_by_xpath("//*[@autocomplete='off']").send_keys("python")

    # use xpath by input lable
    driver.find_element_by_xpath("//input[@autocomplete='off']").send_keys("python")
    driver.find_element_by_xpath("//input[@id='kw']").send_keys("python")
    driver.find_element_by_xpath("//input[@name='wd']").send_keys("python")

    # use 层级关系定位  by father
    driver.find_element_by_xpath("//span[@id='s_kw_wrap']/input").send_keys("python")
    driver.find_element_by_xpath("//form[@id='form']/span/input").send_keys("python")
  • 相关阅读:
    redis基本介绍搭建篇
    Percona XtraDB Cluster集群
    path模块
    vue相关
    Vue首页加载过慢 解决方案
    从用户输入url到页面最后呈现 发生了些什么?
    cookie
    javascript中怎么判断对象{}为空
    jquery之stop()的用法
    跨域
  • 原文地址:https://www.cnblogs.com/shanliguniang/p/10644351.html
Copyright © 2011-2022 走看看