我是靠谱客的博主 迷路篮球,这篇文章主要介绍基于java,selenium选择下拉框的某一个选项,现在分享给大家,希望可以做个参考。

//打印出所有选项值

        Select sel = new Select(driver1.findElement(ById.xpath(".//*[@id='GangManId']")));
        List<WebElement> options = sel.getOptions();
        for (WebElement option : options) {
            System.out.println(option.getText()); //Prints "Option", followed by "Not Option"
        } 

//使用name值选中
        WebElement mySelectElm = driver1.findElement(By.id("GangManId")); 
        Select mySelect= new Select(mySelectElm);
        mySelect.selectByVisibleText("于庆洋");

//使用value值选中

WebElement mySelectElm = driver1.findElement(By.id("GangManId")); 
        Select mySelect= new Select(mySelectElm);
        mySelect.selectByValue("10");

最后

以上就是迷路篮球最近收集整理的关于基于java,selenium选择下拉框的某一个选项的全部内容,更多相关基于java,selenium选择下拉框内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(106)

评论列表共有 0 条评论

立即
投稿
返回
顶部