RE: Difference between perform() and build().perform()

Difference between perform() and build().perform()

Add Comment
2 Answers

In Webdriver, handling keyboard events and mouse events (including actions such as Drag and Drop or clicking multiple elements With Control key) are done using the advanced user interactions API . It contains Actions and Action classes which are needed when performing these events. In order to perform action events, we need to use org.openqa.selenium.interactions.Actions class.

The build() method is used compile all the listed actions into a single step.
we have to use build() when we are performing sequence of operations and no need to use only if we are performing single action.

example where build() required
Actions builder = new Actions(driver);

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

example where build is not required

WebElement draggable = driver.findElement(“draggable”)); 

WebElement droppable = driver.findElement(“droppable”)); 
new Actions(driver).dragAndDrop(draggable, droppable).perform();
in the above code we are performing just a single operations so no need to use build()
Default Answered on February 18, 2019.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.