如何验证该复选框是否已被单击?

如何验证该复选框是否已被单击?

我的代码无法验证是否单击了此复选框。无论其选中还是未选中,它都会在每次迭代中单击该框。 我尝试了各种方法,但是都没有工作,因为期望值不匹配而引发错误。随后会检查和取消检查

continent: {
  continentName,//the id
  planetName //id of the belonging planet
},city: {
  cityName,//the id
  countryName,// id of the belonging country
  continentName,//id of the belonging continent
  planetName //id of the belonging planet
}
bobostst 回答:如何验证该复选框是否已被单击?

您可以预先使用isSelected命令轻松地对其进行验证。

https://www.protractortest.org/#/api?view=webdriver.WebElement.prototype.isSelected

尝试:

const isChecked = await checkbox.isSelected();
if (!isChecked) {
    // perform click actions here
} else {
    console.log('Checkbox was already clicked : ' + bEnabled);
}
,

您可以轻松检查复选框是否已选中

        var isChecked_1 = $(this).is(":checked");
        if (isChecked_1) {
              // checked action
        }
        else {
             //  Unchecked action
        }
本文链接:https://www.f2er.com/3157326.html

大家都在问