求python selenium4,能定位select并将选项改为'Closed' 网页源码如下: [td] [url=]Open[/url] Closed Onhold Open Rejected Resolved Working [img][/img] [/td] 并将, 选项
[Python] 纯文本查看 复制代码from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import Select driver = webdriver.Chrome() driver.get("你的网页地址") select_element = driver.find_element(By.ID, "STATUSID") select = Select(select_element) select.select_by_visible_text("Closed") driver.quit()
[Python] 纯文本查看 复制代码Select(driver.find_element(By.ID,“STATUSID”)).select_by_visible_text(“Closed”) 适用于Python环境
网页有javascript,先定位元素使用click后再定位才能使用. driver.find_elements(By.XPATH,'//*[@id="Inline_TaskForm"]/div[4]/table/tbody/tr[1]/td[4]')[0].click() # 获取下拉选择框元素 select = driver.find_elements(By.NAME,"STATUSID")[0] # 设置下拉选择框的值为"Closed" Select(select).select_by_value("3")