javascript 如何测试 CasperJS 中是否存在选择器?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12253623/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 15:43:03 来源:igfitidea点击:
How to test if selector exists in CasperJS?
提问by Henley Chiu
I know I can use:
我知道我可以使用:
casper.test.assertExists(#selector);
But I want to actually store if it exists in a boolean variable.
但我想实际存储它是否存在于布尔变量中。
I.e. something like this:
即这样的事情:
var exists = SelectorExists(#selector);
回答by Henley Chiu
I just found out:
我刚刚发现:
if(!casper.exists('#selector')){
#selector doesn't exist
}