Can anybody tell me the difference between build.perform()
and perform()
in Selenium actions?
Example:
actions.moveToElement(menuHoverLink).perform();
and
actions.moveToElement(menuHoverLink).build().perform();
In your scenario it wont make a difference using both. The difference occurs at place when you have multiple actions to be performed like:
Actions builder = new Actions(driver);
builder.clickAndHold(element1)
.clickAndHold(element2)
.click()
.build()
.perform();
in the above code we are performing more than one operations so we have to use build() to compile all the actions into a single step. Thus build() method is used compile all the listed actions into a single step. We use build() when we are performing sequence of operations and no need to use if we are performing single action.
A bit late to the party, but you don't have to use build()
unless you want to pass an IActions
object, as build()
is done by perform()
(see WebDriver Actions.Perform() or Actions.Build().Perform())