1

我正在使用 chrome 驱动程序和 windows 10 操作系统。通过使用选择类,我能够从选择标签中找到选项。但无法通过 index 或 visibleText 或任何选择选项。

<select class="pull-left" name="status">
        <option value="">Status</option>
        <option class="select-value" value="Valid" >Valid</option>
        <option class="select-value" value="Ivalid">Invali</option>
</select>

硒代码-

    @FindBy(xpath="//select[@name='status']")
    WebElement drop;


    Select sel=new Select(drop);
    List<WebElement> ls=sel.getOptions();
    for (WebElement webElement : ls) {
        System.out.println(webElement.getText());
    }
    sel.selectByVisibleText("Status");

控制台输出:-

 org.openqa.selenium.WebDriverException: unknown error: a.tagName.toUpperCase is not a function 
    (Session info: chrome=56.0.2924.87) 
    (Driver info: chromedriver=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT 10.0.14393 x86_64) (WARNING: The server did not provide any stacktrace information)
    Command duration or timeout: 55 milliseconds
    Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:49:13 -0700'
4

0 回答 0