没有build()的动作:
Actions actions = new Actions(driver);
actions.doubleClick(element).perform();
这似乎很好用,而无需在perform()之前调用build()。有什么区别?
答案 0 :(得分:0)
从Java绑定中的源代码中,build()
和perform()
的定义很简单:
/**
* Generates a composite action containing all actions so far, ready to be performed (and
* resets the internal builder state, so subsequent calls to {@link #build()} will contain fresh
* sequences).
*
* @return the composite action
*/
public Action build() {
Action toReturn = new BuiltAction(driver, new LinkedHashMap<>(sequences), action);
action = new CompositeAction();
sequences.clear();
return toReturn;
}
/**
* A convenience method for performing the actions without calling build() first.
*/
public void perform() {
build().perform();
}
显然,只需执行简单的调用构建,因此使用perform()
或build().perform()
之间没有功能上的区别