Ask a Question

Clicking certain area of an object on different screen sizes

SOLVED
nastester
Frequent Contributor

Clicking certain area of an object on different screen sizes

I am encountering an issue where an object is clickable (to bring up a menu) but only in the upper right hand corner of it.  I cannot seem to map just the clickable area so when I do a test, I need to include coordinates of the object so that the correct area is clicked, thus opening the menu for additional items to be clicked. 

This works fine for me but when run on a co-worker's computer the test fails because our screen sizes are different so the object is not clicked in the right location.

 

Is there a way around this? 

 

Thanks!

16 REPLIES 16
Marsha_R
Champion Level 2

Yes.  Click by the object name instead of coordinates.  You have just found out why coordinates are not particularly reliable.

 

 

nastester
Frequent Contributor

This does not work for this scenario. Only clicking the top right of the object opens the menu. And we have found that having coordinates causes the test to fail on other screens since positioning is not the same. 

Coordinates will always cause that issue.

Show us the detailed object spy results from that button please.
nastester
Frequent Contributor

I attached the object spy results and a picture of the actual object with the clickable area circled in red. 

For object spy, we need the Advanced view please

Marsha_R_0-1631223556006.png

 

AlexKaras
Champion Level 2

Hi,

 

 I need to include coordinates of the object so that the correct area is clicked

Can you provide your code for this action?

 

Regards,
  /Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
nastester
Frequent Contributor

Sorry about that! Attached all

nastester
Frequent Contributor

This particular test is keyword based but the underlying code is:

page.panelDevicecardcontainer.panelDevicedatacontainer.Click(144, 11);  //works for me

 

When my coworker records the click action, he of course gets different coordinates: 
//page.panelDevicecardcontainer.panelDevicedatacontainer.Click(111,6);

 

This doesn't work because the "object" to open the menu (see earlier screenshot) as the object seemingly needs to be clicked in top right only:
//page.panelDevicecardcontainer.panelDevicedatacontainer.Click();

Hi,

 

page.panelDevicecardcontainer.panelDevicedatacontainer.Click(144, 11);  //works for me

You may try to click, say 10 pixels left from the right edge of control and 5 pixels down from its top to hit the clickable area. Usually this works when test code is executed on systems with different screen resolutions. E.g.:

var pointX = page.panelDevicecardcontainer.panelDevicedatacontainer.Left + page.panelDevicecardcontainer.panelDevicedatacontainer.Width - 10;
var pointY = page.panelDevicecardcontainer.panelDevicedatacontainer.Top -  5;
page.panelDevicecardcontainer.panelDevicedatacontainer.Click(pointX, pointY);  // clicks 10 pixels left from the right control's edge and 5 pixels down from the top

 

Regards,
  /Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
cancel
Showing results for 
Search instead for 
Did you mean: