Ask a Question

Is there any way to check the Click action.

SOLVED
shankar_r
Community Hero

Is there any way to check the Click action.

I'm getting error message as "There was an attempt to perform an action at a point, which is beyond the screen." while performing click action on a particular object.

 

Can i get return value or something to know whether click operation was success or fail at the run time? I know i will get a error message as mentioned above.


Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

“You must expect great things from you, before you can do them”

Extension Available

8 REPLIES 8
tristaanogre
Esteemed Contributor

The error message you got is your return value... the click failed.  It seems like the state of the system before you attempt the click is the more pertinent question... is the application in a state where the click will pass or fail?  In this case, the component or object is not in the right place on screen... I'd throw a check in on that before I do the click, especially if this is a common occurence.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

Do i get a return string or Object in below code?

var tempCheck  = Aliases.******.ServerControlMenuBar.Click();

Log.Message(tempCheck);

 

What i want to do is, If the click operation fails then i should close the window hence if i get any return value then i will do my staffs based on that.


Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

“You must expect great things from you, before you can do them”

Extension Available

tristaanogre
Esteemed Contributor

No. Most of those UI interaction actions don't have any return value.

 

As mentioned, your check should first be on ServerControlMenuBar to make sure it's in a state to allow the Click, not on the click action itself.

 

I suppose you COULD wrap your click action in try/catch logic but I know there are some limitations... I'm not sure try/catch will capture those kinds of errors.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

I tried the try/catch but it is not catching this error.


Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

“You must expect great things from you, before you can do them”

Extension Available

tristaanogre
Esteemed Contributor


@shankar_r wrote:

I tried the try/catch but it is not catching this error.


Yeah, I didn't think it would.

So, since "Click" doesn't have a return value, you're left with doing your detection elsewhere.  Which, actually, is better automation anyways.  Unless it is pertinent to the test case, you don't want to attempt an action unless you are sure that you CAN attempt the action.  In the case of your error message, you need to make sure that the component you are clicking on is actually on screen and available for being clicked upon.  This is part of the automation process itself and, therefore, should be taken into consideration when developing your automation code.

That said... the error you indicated usually means, to me, one of several things:

1) There are co-ordinates in your call to Click (e.g. MyObject.Click(20,5)).  It is possible that the component in question has changed in size so that whatever co-ordinates are passed in are no longer valid.  When making calls to "Click" or "ClickButton", I tend to prefer to leave the co-ordinates out.  This has the default of clicking in the center of the component every time without needing to worry about the dimensions of the component.
2) The component in question is somehow not present within the viewing range of the screen.  It could be that you need to execute some sort of "scroll" action on your application to make it available.  This is especially true in some web applications or with some desktop components that scroll within a form.
3) The resolution of the machine one which the playback occurs is insufficient to fully display the application under test.  This is a slightly bigger problem in that the environment on playback is different than the environment on development... or, for that matter, the environment on playback is out of scope  based upon the requirements of the application under test.  If the application undertest is developed expecting at least an 800 x 600 screen resolution and you're only running at 400X250 or something, then that's a problem with the environment.  

There could be other factors but these are the things that I would look at to solve your problem that may not require any kind of "return" value on "click".  If, however, you are expecting "Click" to work 100% of the time, you are left with 2 things: 1) You've discovered a bug in your application that the component is not presented properly to the end user or 2) You've discovered a bug in your automation where you are not properly detecting and adjusting the positioning of your components before you attempt an action.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

Thanks @tristaanogre brief explanation. I learned some new things.

 

In my scenario,I have 3 test cases.

1 st test case passed as expected.

2 nd test case fails due to click on invalid x,y place. it is bug in application. hence this test case marked as failure.

if i want to run a 3 rd test case that window should be closed in-order to do the execution.(Since 2nd and 3rd test case are different types of functionalities). For closing this window i should know when to close.

 


Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

“You must expect great things from you, before you can do them”

Extension Available

tristaanogre
Esteemed Contributor

Turn your test case into a method with a return value of true or false based upon success of the test case... if test case 2 returns true, no need to close the window... if test case 2 returns false, you need to close the window.

This is actually a pretty good methodology for any test case in a test automation environment... it allows you, eventually, to organize your test cases into larger batches where you can make the batch run/execute test cases based upon previous statuses.  

For that matter, it's also a good idea that each test case should be as "atomic" as possible so they can be run without dependency.  If Test Case 3 is fragile enough to break because a previous test case left the application in a bad state, that means that test case 2 didn't have sufficient "tear down" code... nor did test case 3 have sufficient "set up" code.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

Yup...i got the idea...I started doing that. 🙂


Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

“You must expect great things from you, before you can do them”

Extension Available

cancel
Showing results for 
Search instead for 
Did you mean: