from selenium import webdriver import time from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.support.select import Select profile_path = r'C:\Users\songping\AppData\Roaming\Mozilla\Firefox\Profiles\gjihjypg.default' profile = webdriver.FirefoxProfile(profile_path) driver = webdriver.Firefox(profile) driver.get(r"https://www.baidu.com/") element = driver.find_element_by_xpath(".//*[@id='kw']") tag1 = element.tag_name #获取标签属性 t1 = element.text #获取标签属性 c2 = element.get_attribute("class") #也行 print(tag1) print(c2) print(t1)
from selenium import webdriver import time driver = webdriver.Firefox() driver.get("https://www.baidu.com") t = driver.find_element_by_id("su").get_attribute("class") print(t)
from selenium import webdriver import time driver = webdriver.Firefox() driver.get("https://www.baidu.com") d = driver.find_element_by_id("su").is_displayed() print(d)
标签:jquery,定位,webdriver,selenium,driver,element,print,import,css From: https://www.cnblogs.com/pingzi66-ww/p/17100266.html