Question

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

**Moderation Team has archived post**

This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.

Correct Answer
January 9, 2018 - 10:08am

You mean to say that when we send an enter key to a control, Pega Robotics Studio doesn't wait for any page to be created or check for any pre-conditions to be satisified unlike perform click method ?

That is more or less correct. In general, you cannot call a method for a control that is not matching. With that said, you can use SendKeys to interact with controls that are not necessarily matched. For example... say you have a Webpage with a link inside - SendKeys requires that the windows frame is matched (since this is where the method for SendKeys exists) but you can still send an enter key to the link in the webpage (if you have focus on it) ... so there is no check that the underlying link is matched in this case. 

---

Also, you mentioned "Click" Event but I was referring to Perform Click method. Could you elaborate more on this ?

Click() == PerformClick(). It was mistyped. As I said earlier - just to emphasize, in general, you cannot call a method for a control that is not matching. PerformClick method exists solely on the control, in most situations. Since that is the case, the control must be matched before the click can happen.

So SendKeys has the same rules as PerformClick. The control that is calling the method must match and will not be called until the originating control matches.

Comments

Keep up to date on this post and subscribe to comments

Pega
January 9, 2018 - 4:23am

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.

January 9, 2018 - 6:52am
Response to Asif Hasan

Hi Asif,

Thanks for the response but I am not very clear with the answer. I didn't understand which page loading are we talking about ? You mean to say that when we send an enter key to a control, Pega Robotics Studio doesn't wait for any page to be created or check for any pre-conditions to be satisified unlike perform click method ? Also, you mentioned "Click" Event but I was referring to Perform Click method. Could you elaborate more on this ?

Regards,

Shivanshu

Pega
January 9, 2018 - 10:08am
Response to ShivanshuK

You mean to say that when we send an enter key to a control, Pega Robotics Studio doesn't wait for any page to be created or check for any pre-conditions to be satisified unlike perform click method ?

That is more or less correct. In general, you cannot call a method for a control that is not matching. With that said, you can use SendKeys to interact with controls that are not necessarily matched. For example... say you have a Webpage with a link inside - SendKeys requires that the windows frame is matched (since this is where the method for SendKeys exists) but you can still send an enter key to the link in the webpage (if you have focus on it) ... so there is no check that the underlying link is matched in this case. 

---

Also, you mentioned "Click" Event but I was referring to Perform Click method. Could you elaborate more on this ?

Click() == PerformClick(). It was mistyped. As I said earlier - just to emphasize, in general, you cannot call a method for a control that is not matching. PerformClick method exists solely on the control, in most situations. Since that is the case, the control must be matched before the click can happen.

So SendKeys has the same rules as PerformClick. The control that is calling the method must match and will not be called until the originating control matches.

January 13, 2018 - 9:45am
Response to Mitchell

Hey Mitchell,

This makes it clear ! Thanks a lot

Regards,

Shivanshu