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

selenium - webdriver - 定位一组元素

时间:2018-05-12 16:47:08      阅读:198      评论:0      收藏:0      [点我收藏+]

标签:baidu   link   结果   python   功能   python爬虫   style   click   高薪   

八种方法:

find_elements_by_id()
find_elements_by_name()
find_elements_by_class_name()
find_elements_by_tag_name()
find_elements_by_link_text()
find_elements_by_partial_link_text()
find_elements_by_xpath()
find_elements_by_css_selector()

  

实例:

from selenium import webdriver
from time import sleep

driver = webdriver.Chrome()
driver.get("http://www.baidu.com")

driver.find_element_by_id("kw").send_keys("selenium")
driver.find_element_by_id("su").click()
sleep(5)

texts = driver.find_elements_by_xpath("//div/h3/a")

for t in texts:
    print(t.text)

driver.quit()

  

运行结果:

selenium

selenium教程-90天从入门到高薪【学习必看】

Selenium - Web Browser Automation
Selenium_百度百科
Selenium - Web Browser Automation
官网
功能自动化测试工具——Selenium篇
自动化测试工具Selenium入门 - CSDN博客
python爬虫从入门到放弃(八)之 Selenium库的使用 - pytho..._博客园
selenium用法详解 - 道高一尺 - 博客园
selenium中文网 – selenium安装、selenium使用、selenium中文、...
selenium-CSDN下载
selenium自动化测试资源整理(含所有版本chrome、chrome..._CSDN博客
自动化测试_2017新编自动化测试selenium课程

selenium_"0基础"到熟练只要4个月_月薪过万不是梦

【亚马逊】买selenium就上Z.CN_亚马逊海外购大牌"惠"聚_一键真..

  

参考资料:http://www.testclass.net/selenium_python/elements/

selenium - webdriver - 定位一组元素

标签:baidu   link   结果   python   功能   python爬虫   style   click   高薪   

原文地址:https://www.cnblogs.com/studyddup0212/p/9029063.html

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