Question
4
Replies
1777
Views
Accenture
Posted: January 9, 2018
Last activity: January 23, 2018
Closed
Solved
Difference between Send keys {ENTER} method and Perform Click method for Robotic automation
Hi,
I wanted to know what is the difference between send keys {ENTER} method and perform click method. Even though fundamentally both do the same job, I have observed that for some controls, send keys {ENTER} method works faster than perform click and vice-versa. Also, the automation does not work as expected if perform clicks are replaced with send keys {ENTER} method for some controls.
Any Inputs on this ?
Regards,
Shivanshu
Hi Shivanshu,
Thanks for posting on PSC,
You are correct about the faster execution of Send Keys(Enter) method as compare to Click. It's because of "Click" event causes a new page to load and this method will attempt to block until the page has loaded. At this point, you should discard all references to this element and any further operations performed on this element will throw a StaleElementReferenceException.
There are some preconditions for an element to be clicked. The element must be visible and it must have a height and width greater than 0.
SendKeys()
Use this method to simulate typing into an element, which may set its value.
Both simulate user action on the web element. But while SendKeys() tries to perform the action without consideration to anything else Click() has some safeguards, like "stopping" the code from continuing until page load event is received. Also, the method won't try to execute without meeting some preconditions to avoid unexpected behaviour.
Hope it answers your query.