Please see this:
<option data-="OK" value="110">
My Text
</option>
<option data-="OK" value="111">
My Text 2
</option>
I want to find specific element, so i have try this:
option[contains(text(),'My Text')]
So i this case i found 2 WebElements
while i want to find the one that i want, i also try this:
option[text()='My Text']
But in this case nothing found.
Any suggestions ?
Edit:
<optgroup label="some text">
</optgroup>
试试这个:
option[normalize-space(text())='My Text']
Is this a dropdown you are trying to select value from?
for drop-downs you can try,
WebElement element=driver.findElement(By.xpath(".//*[@YOUR-XPATH-HERE"));
Select se=new Select(element);
se.selectByIndex(0);
or
se.selectByVisibleText("My Text");
or
se.selectByValue("110");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.