//input复选框
    static void inputCheckBox(By by) {
        //查找复选框对象
        WebElement orangeCheckbox = driver.findElement(by);
        //如果此复选框没有选中,就点击一下
        if (!orangeCheckbox.isSelected())
            orangeCheckbox.click();
        //断言复选框是否被选中
        Assert.assertTrue(orangeCheckbox.isSelected());
    }

    //input复选框,取消选择
    static void inputCheckBoxDe(By by) {
        //查找复选框对象
        WebElement orangeCheckbox = driver.findElement(by);
        //如果此复选框已经选中,就点击一下
        if (orangeCheckbox.isSelected())
            orangeCheckbox.click();
        //断言复选框处于非选中状态
        Assert.assertFalse(orangeCheckbox.isSelected());
    }

    //input复选框,让所有复选框处于选中状态
    static void inputCheckBoxAll(By by) {
        //查找单选框所有的选项,存储到一个list中
        List<WebElement> checkboxs = driver.findElements(by);
        for (WebElement checkbox : checkboxs) {
            checkbox.click();
        }
    }

 

Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐