码迷,mamicode.com
首页 > 编程语言 > 详细

Selenium+python---xpath定位

时间:2019-04-02 18:26:17      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:ble   inf   for   put   odi   other   mamicode   image   path   

 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")

 

Selenium+python---xpath定位

标签:ble   inf   for   put   odi   other   mamicode   image   path   

原文地址:https://www.cnblogs.com/shanliguniang/p/10644351.html

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