[英]How to check if a button is disabled?
Hello I have the following code: 您好,我有以下代码:
async function pressNext(nightmare) {
const check = await check_nextButton(nightmare);
const disabled= await check_disabled();
if(check&&disabled) {
await nightmare.click('#example_next');
await extractInfo(nightmare);
return pressNext(nightmare);
}
return null;
}
It is supposed to click the next button on a table as long as it exists , the problem is that the button exists even after it becomes disabled, so I can't think of any way to check if the "next button" is disabled The check disabled function is just something I've tried but didn't work , so I need to somehow make that function be true only if the #example_next
is not disabled EDIT: image of Next enabled 只要存在,就应该单击表上的下一个按钮,问题是该按钮即使在被禁用后也仍然存在,所以我想不出任何方法来检查“下一个按钮”是否被禁用。检查禁用的功能只是我尝试过的但没有起作用,因此,仅在
#example_next
未禁用的情况下 ,我才需要使该功能为true编辑: Next的图像已启用
image of Next disabled 下一个禁用的图像
I tried comparing the classNames and that doesn't work 我试图比较classNames,这是行不通的
You can use .disabled
: 您可以使用
.disabled
:
if(!your_button.disabled){ //if not disabled
# Do something
} else {
# Do something
}
So I've fixed it guys , I've made a function that fixes it , verifying if the selector for the disabled class exists , i the folllowing 所以我已经修复了它,我做了一个修复它的函数,验证了禁用类的选择器是否存在,如下
async function check_disabled(nightmare){
return nightmare.exists('.paginate_button.next.disabled');
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.