WebDriver Actions.Perform()或Actions.Build().Perform() [英] WebDriver Actions.Perform() or Actions.Build().Perform()

查看:859
本文介绍了WebDriver Actions.Perform()或Actions.Build().Perform()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C#中使用Selenium2 WebDriver

I use Selenium2 WebDriver with C#

Actions.Build-返回一个复合IAction,可用于执行操作. (IActions具有Perform方法来执行操作) Actions.Perform-执行当前构建的动作.

Actions.Build - returns a composite IAction which can be used to perform the actions. (IActions has a Perform method to execute the actions) Actions.Perform - Performs the currently built action.

在大多数示例中,请使用以下操作:

In most of the examles use Actions like this:

new Actions(IWebDriverObj).actions...Build().Perform()

但这也可以

new Actions(IWebDriverObj).actions...Perform()  //no Build before Perform

在Perform()或Build()仅出于某种兼容性目的之前,是否有必要使用Build()?

Is it necessary to use the Build() before the Perform() or Build() is for some compatibility purpose only?

预先感谢您的回答

推荐答案

始终牢记Selenium是开源的.

Always keep in mind that Selenium is open source.

WebDriver/Interactions/Actions.cs的来源是在这里,您可以清楚地看到Perform()包括Build(),所以答案是否定的,您不需要在执行之前进行构建,除非您想要不执行就传递构建的IAction.

The source of WebDriver/Interactions/Actions.cs is here, clearly you can see Perform() includes Build(), so the answer is no, you don't need to build before perform, unless you want to pass the built IAction around without performing.

/// <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();
}

此外,对于任何其他阅读此帖子的人:

Also, for anyone else reading this post:

Java绑定:build()包含在perform()中.来源: interactions/Actions.java

Java binding: build() is included in perform(). Source: interactions/Actions.java

Ruby/Python:只有perform,没有这样的东西叫build.来源: action_chains.py action_builder.rb

Ruby/Python: only have perform, no such thing called build. Source: action_chains.py, action_builder.rb

这篇关于WebDriver Actions.Perform()或Actions.Build().Perform()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆