WebDriver Actions.Perform () or Actions.Build (). Run ()

I am using Selenium2 WebDriver with C #

Actions.Build - Returns a composite IAction that can be used to perform actions. (IActions has a Perform method to perform actions) Actions.Perform - Performs the current action.

In most examples, use actions like this:

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

but it also works

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

Do I need to use Build () before the Perform () or Build () functions are for a specific compatibility purpose only?

Thanks in advance for your answers.

+3
c # selenium selenium-webdriver webdriver
source share
2 answers

Always remember that Selenium is open source.

The source of WebDriver/Interactions/Actions.cs is here , obviously, you can see that Perform() includes Build() , so the answer is no, you do not need to build before execution if you do not want to pass the built-in IAction circle without execution.

 /// <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 others who read this post:

Java Binding: Build() included in Perform() . Source: interactions / Actions.java

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

+11
source share

Actually, .perform() includes .build() .

So you can only write: new Actions(IWebDriverObj).actions....perform()

+2
source share

All Articles