我正在使用Java/Selenium测试JavaScript API.
我在Java端发出这些命令,
executor.executeScript("setName('Hello');");
// Thread.sleep(2000);
String output = (String)executor.executeScript("return getName()");
assertEquals(output, "Hello");
Run Code Online (Sandbox Code Playgroud)
在JavaScript方面,这是一个异步函数,因此它需要一些时间并设置变量.
function setName(msg) {
// simulate async call
setName(function(){name = msg;},1000);
}
Run Code Online (Sandbox Code Playgroud)
我需要等待这个异步函数完成,然后再转到Java assertEquals()
执行的下一行.
如果不在Thread.sleep()
Java端使用,有没有办法实现这一点.
谢谢
我配置了maven-checkstyle-plugin(v2.5)和maven-eclipse-plugin(v2.8).
一切都按预期工作但我一介绍,
模块名称="SuppressWarningsHolder" 和/或 模块名称="SuppressWarningsFilter"
到我的checkstyle-config.xml,我开始在构建项目时遇到问题.
这是我得到的:
[ERROR] BUILD ERROR
1> [INFO] ------------------------------------------------------------------------
1> [INFO] Failed during checkstyle configuration
1>
1>EXEC : Embedded error : cannot initialize module TreeWalker - Unable to instantiate SuppressWarningsHolder
1> Unable to instantiate SuppressWarningsHolderCheck
Run Code Online (Sandbox Code Playgroud)
如果我删除SuppressWarningsHolderCheck,我会得到相同的SuppressWarningsFilter错误.
有任何想法吗?
谢谢
public boolean typeMatch(char c1, char c2) {
if (c1 == '{' || c1 == '}') {
return (c2 == '{' || c2 == '}');
} else if (c1 == '(' || c1 == ')') {
return (c2 == '(' || c2 == ')');
} else if (c1 == '[' || c1 == ']') {
return (c2 == '[' || c2 == ']');
} else {
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
我在我的程序中有上面的代码,我想知道是否有更好的方法来实现这个方法而不使用大量的if/else语句.