八种方法:
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 webdriverfrom time import sleepdriver = 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()
运行结果:
seleniumselenium教程-90天从入门到高薪【学习必看】Selenium - Web Browser AutomationSelenium_百度百科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 - 定位一组元素
原文地址:https://www.cnblogs.com/studyddup0212/p/9029063.html