首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WebDriver Actions.Perform()或Actions.Build().Perform()

WebDriver Actions.Perform()或Actions.Build().Perform()
EN

Stack Overflow用户
提问于 2013-05-08 16:18:29
回答 2查看 8.6K关注 0票数 6

我将Selenium2 WebDriver与C#一起使用

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

在大多数示例中,使用的操作如下所示:

代码语言:javascript
复制
new Actions(IWebDriverObj).actions...Build().Perform()

但这也是可行的

代码语言:javascript
复制
new Actions(IWebDriverObj).actions...Perform()  //no Build before Perform

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

提前感谢你的回答

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-05-08 18:15:34

请始终记住,Selenium是开源的。

WebDriver/Interactions/Actions.cs的源代码是here,显然你可以看到Perform()包含了Build(),所以答案是否定的,你不需要在执行之前构建,除非你想在不执行的情况下传递构建的IAction

代码语言:javascript
复制
/// <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.pyaction_builder.rb

票数 13
EN

Stack Overflow用户

发布于 2013-05-08 17:54:28

实际上,.perform()包含一个.build()

所以你只能写:new Actions(IWebDriverObj).actions....perform()

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16435798

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档