from selenium import webdriverfrom selenium.webdriver.support.wait import WebDriverWaitfrom selenium.webdriver.support import expected_conditions as ECfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.support.ui import Selectdriver = 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()