selenium 获取页面<input>标签的个数和各个属性的值

获取页面某个标签的数量、id、name、class的值,来辅助定位

        List<WebElement> lw =driver.findElements(By.tagName("input"));
        System.out.println(lw.size());
        for (WebElement webElement : lw) {
//            获取input输入框 属性id、name、Class 和文本框的值
            System.out.println(webElement.getAttribute("id")+" | "+ webElement.getAttribute("name")+" | "
            +webElement.getAttribute("class")+" | " +webElement.getText().toString());
        }

猜你喜欢

转载自www.cnblogs.com/zddwork/p/11328619.html
今日推荐