Can we use two strings in 'selectByVisibleText

2019-09-03 22:13发布

I have a Situation where my String is getting merged with symbol '»' after running a script. So after detecting an element from Drop-down element i have to Select it only by visible Text but i have to add » before my String.

Is their any way to handle this?

1条回答
做个烂人
2楼-- · 2019-09-03 22:45

You can do one thing in such a case:

WebElement web = driver.findElement(By.xpath("//select"));
List<WebElement> lst2 = web.findElements(By
        .xpath(".//option[contains(text(),'<yourText>')]"));
    for (WebElement option : lst2) {
    if (!option.isSelected()) {
        option.click();
    }
}

Hope this would help, thanks.

查看更多
登录 后发表回答