selenium - webdriver - 定位一组元素

八种方法:

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/

猜你喜欢

转载自www.cnblogs.com/studyddup0212/p/9029063.html