#coding:utf-8 from selenium import webdriver import time url ='http://www.baidu.com' driver = webdriver.Chrome() driver.get(url) time.sleep(1) e=driver.find_element_by_xpath('//*[@id="lg"]/img') print e print e.text print e.id print e.tag_name print type(e) time.sleep(1) driver.quit()
e.text 读取元素内容
e.tag_name 读取元素标签名