[英]How to select an option from drop down in selenium webdriver. The element is not a 'select' element
<svg viewBox="0 0 24 24" style="display: inline-block; fill: rgb(224, 224, 224); height: 24px; width: 24px; transition: all 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms; position: absolute; right: 0px; top: 22px; -webkit-user-select: none;"><path d="M7 10l5 5 5-5z"></path></svg>
<path d="M7 10l5 5 5-5z"></path>
I've attempted, using as a container, using the action class to hover over, using the select class but none seem to be working.我尝试过,用作容器,使用操作类悬停,使用选择类,但似乎都没有工作。
If the element is not a select element then it's still a WebElement.如果元素不是选择元素,那么它仍然是一个 WebElement。 Display the options and find the xpath for the option and if you need to select a particular one, use the find by text as follows.显示选项并找到该选项的 xpath,如果您需要选择一个特定的选项,请使用按文本查找,如下所示。 You may need to have a wait in place to wait for the option to display.您可能需要等待一段时间才能显示该选项。
Example: 1. Click on the drop down element to display the list of items.示例: 1. 单击下拉元素以显示项目列表。 2. Use the following to find the option and then select it 2.使用下面的找到该选项,然后选择它
WebElement yourElement = driver.findElement(By.xpath("//*[contains(text(),'THE OPTION TEXT YOURE LOOKING FOR')]"));
yourElement.click();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.