本文介绍了我们可以在Seleniumwebdriver的'selectByVisibleText'方法中使用两个字符串吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在运行脚本后,我的字符串与符号'»'合并在一起.因此,在从下拉"元素中检测到元素之后,我只能通过可见的文本来选择它,但必须在字符串之前添加».

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?

推荐答案

在这种情况下,您可以做一件事:

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.

这篇关于我们可以在Seleniumwebdriver的'selectByVisibleText'方法中使用两个字符串吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 05:44