from selenium import webdriver from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import Select driver = webdriver.Chrome() driver.get("https://www.baidu.com/") driver.maximize_window() # 点击设置按钮 driver.find_element_by_xpath(‘//div[@id="u1"]//a[@name="tj_settingicon"]‘).click() # 等待元素可见 WebDriverWait(driver,20).until(EC.visibility_of_element_located((By.XPATH,‘//a[text()="高级搜索"]‘))) # 点击高级搜索 driver.find_element_by_xpath(‘//a[text()="高级搜索"]‘).click() # 选择所有格式 select_ment = driver.find_element_by_xpath(‘//select[@name="ft"]‘) s = Select(select_ment) s.select_by_visible_text(‘所有格式‘) driver.quit()
原文地址:https://www.cnblogs.com/666666pingzi/p/10568888.html
时间: 2024-11-02 04:31:25