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标签
select_ment = driver.find_element_by_xpath('//select[@name="ft"]')
# 实例化select对象
s = Select(select_ment)
# 执行操作
s.select_by_visible_text('所有格式')
# 退出浏览器
driver.quit()