我将Selenium2 WebDriver与C#一起使用
Actions.Build -返回可用于执行操作的复合IAction。(IActions有一个执行操作的方法) Actions.Perform -执行当前构建的操作。
在大多数示例中,使用的操作如下所示:
new Actions(IWebDriverObj).actions...Build().Perform()但这也是可行的
new Actions(IWebDriverObj).actions...Perform() //no Build before Perform在Perform()或Build()只是出于某些兼容性目的之前,是否有必要使用Build()?
提前感谢你的回答
发布于 2013-05-08 18:15:34
请始终记住,Selenium是开源的。
WebDriver/Interactions/Actions.cs的源代码是here,显然你可以看到Perform()包含了Build(),所以答案是否定的,你不需要在执行之前构建,除非你想在不执行的情况下传递构建的IAction。
/// <summary>
/// Builds the sequence of actions.
/// </summary>
/// <returns>A composite <see cref="IAction"/> which can be used to perform the actions.</returns>
public IAction Build()
{
CompositeAction toReturn = this.action;
this.action = new CompositeAction();
return toReturn;
}
/// <summary>
/// Performs the currently built action.
/// </summary>
public void Perform()
{
this.Build().Perform();
}另外,对于其他阅读这篇文章的人:
Java绑定:perform()中包含了build()。来源:interactions/Actions.java
只有perform,没有叫做build的东西。来源:action_chains.py,action_builder.rb
发布于 2013-05-08 17:54:28
实际上,.perform()包含一个.build()。
所以你只能写:new Actions(IWebDriverObj).actions....perform()
https://stackoverflow.com/questions/16435798
复制相似问题