如何通过geb测试select2

用户3091180

我正在尝试从select2 dropDown列表中选择选项,但我无法这样做这是代码

enter code here

 <select id="addedLanguageId" class="input-large select2-me
 select2-offscreen"    name="language.id" style="width: 200px;"
 tabindex="-1"> <option value="">Select a language</option> <option
 value="1">Aboriginal Dialects</option> <option
 value="2">Afrikaans</option> <option value="3">Ainu</option> <option
 value="4">Akkadian</option> <option value="5">Albanian</option>
 </select>`

我已经尝试了很多类似的东西,$("form").language.id=["4"]或者在网页selectLang{$('#language.id')}和测试中添加了代码selectLang.value('20')我使用的其他概念,如selectLang{$('#language.id')}

dropdownSelectedText {selectLang.find('option', value:selectLang.value()).text()} 

在页面中并使用以下命令进行了测试:

when:
selectLang='Akkadian' 
then:
dropdownSelectedText=='Akkadian'
selectLang.value()=='Akkadian'
内拉吉·巴特(Neeraj Bhatt)

请尝试这个。据我了解,这不是select2问题。我在下面写了硒测试。它同时适用于select和select2两者。

WebDriver driver=new FirefoxDriver();
    driver.get("http://ivaynberg.github.io/select2/");
    WebElement select=driver.findElement(By.id("e1"));
    List<WebElement> options = select.findElements(By.tagName("option"));
    for(WebElement option : options){
        if(option.getText().equals("California")) {
            option.click();
            break;
        }
    }

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章