我面临着从下拉列表中选择一个选项的问题。这个网站是https://uk.farnell.com。在“搜索”文本框之前有一个“全部”下拉列表。我想从落地中选择“陶瓷电容器”。我尝试了可能的方法,比如使用
发布于 2020-10-16 06:22:37
xpath for All - .//div[@id='catContainer']
陶瓷电容器用xpath . .//option[text()='Ceramic Capacitors']
发布于 2020-10-16 06:37:04
按第三个索引或可见文本进行选择。
driver.get('https://uk.farnell.com/')
Select(driver.find_element_by_id('categoryIdBox')).select_by_index(3)
Select(driver.find_element_by_id('categoryIdBox')).select_by_visible_text("Ceramic Capacitors") 导入
from selenium.webdriver.support.select import Select发布于 2020-10-20 05:40:58
请尝试使用以下代码:
WebElement dropdownlist=Driver.findElement(By.id("categoryIdBox"));
Select listbox = new Select(dropdownlist);
listbox.selectByVisibleText("Ceramic Capacitors");https://stackoverflow.com/questions/64383551
复制相似问题