Question
Accenture
IN
Last activity: 23 Jan 2018 4:48 EST
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
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Pegasystems Inc.
US
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 ?
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.
EPAM Systems, Inc.
ES
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.
Accenture
IN
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
Accepted Solution
Pegasystems Inc.
US
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 ?
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.
Accenture
IN
Hey Mitchell,
This makes it clear ! Thanks a lot
Regards,
Shivanshu