Topic
  • 17 replies
  • Latest Post - ‏2014-07-21T14:31:33Z by NaveenEshwar
Stonger
Stonger
33 Posts

Pinned topic .click() misses the mark in RFT

‏2013-10-08T21:13:17Z |

I've been noticing some quirky behaviour in RFT 8.5 (Java). Keep in mind I am doing everything programatically.

Every once in a while, when I call a .click() command on a GuiTestObject, RFT fails to click at the correct spot. It usually clicks just to the left or just above of where the object actually is. I can usually remedy the situation by using .click(Point pt) instead, and find some coordinates that work after a bit of trial and error. However, I don't believe this is a necessarily reliable method. I thought we had something clever when we tried to aim for the center of the object like this:

 

Rectangle bounds = (Rectangle) guiObject.getProperty(".bounds");
guiObject.click(new Point(bounds.width / 2, bounds.height / 2));

 

But it's still missing the mark. Any other suggestions would be appreciated.

  • boB
    boB
    6 Posts

    Re: .click() misses the mark in RFT

    ‏2013-10-10T15:16:25Z  

    Hey,

    I've used the below to help click where we needed it. If the object isn't ready yet, it will fire off early, so you may need to throw in a pause before calling it.

    // Gets the center point of the object you want to click.
    Point objectlocation = ((GuiTestObject) object).getScreenPoint();
     
    // LowLevelEvent that strings together moving and clicking.
    LowLevelEvent clickatlocation[] = { mouseMove(objectlocation), delay(250), leftMouseButtonDown(), delay(250), leftMouseButtonUp() };
    getRootTestObject().emitLowLevelEvent(clickatlocation);

    Hope that gives you some ideas.
    boB

  • Stonger
    Stonger
    33 Posts

    Re: .click() misses the mark in RFT

    ‏2013-10-10T19:11:11Z  
    • boB
    • ‏2013-10-10T15:16:25Z

    Hey,

    I've used the below to help click where we needed it. If the object isn't ready yet, it will fire off early, so you may need to throw in a pause before calling it.

    // Gets the center point of the object you want to click.
    Point objectlocation = ((GuiTestObject) object).getScreenPoint();
     
    // LowLevelEvent that strings together moving and clicking.
    LowLevelEvent clickatlocation[] = { mouseMove(objectlocation), delay(250), leftMouseButtonDown(), delay(250), leftMouseButtonUp() };
    getRootTestObject().emitLowLevelEvent(clickatlocation);

    Hope that gives you some ideas.
    boB

    Thank you for the suggestion. I tried it and I'm getting the same result, the mouse still tries to click just above the link and misses it.

  • Newbie07
    Newbie07
    14 Posts

    Re: .click() misses the mark in RFT

    ‏2013-10-11T13:40:33Z  
    • Stonger
    • ‏2013-10-10T19:11:11Z

    Thank you for the suggestion. I tried it and I'm getting the same result, the mouse still tries to click just above the link and misses it.

    Could be please check if the browser resolution is set to 100%. ?

  • Stonger
    Stonger
    33 Posts

    Re: .click() misses the mark in RFT

    ‏2013-10-11T15:17:06Z  
    • Newbie07
    • ‏2013-10-11T13:40:33Z

    Could be please check if the browser resolution is set to 100%. ?

    Do you mean check if the browser is maximized/set on full screen? If you do, then yes it is on full screen.

  • boB
    boB
    6 Posts

    Re: .click() misses the mark in RFT

    ‏2013-10-11T15:17:50Z  
    • Stonger
    • ‏2013-10-10T19:11:11Z

    Thank you for the suggestion. I tried it and I'm getting the same result, the mouse still tries to click just above the link and misses it.

    Is there any chance that the Test Object's size is actually bigger than it's clickable area? With what you have tried and with the default click(), they aim for the middle of the object. I have used this in the past to click a certain section of a button:

    // Gets the center point of the object you want to click.
    Point objectlocation = ((GuiTestObject) object).getScreenPoint();
     
    // A bit of math to help replace the mouse.
    int math = (object.getVisibleArea().height/ 8) * 3;
     
    // Making a new point to click on.
    Point bottomquarter = new Point(objectlocation.x, objectlocation.y + math);
     
    // LowLevelEvent that strings together moving and clicking.
    LowLevelEvent clickatlocation[] = { mouseMove(bottomquarter), delay(250), leftMouseButtonDown(), delay(250), leftMouseButtonUp() };
    getRootTestObject().emitLowLevelEvent(clickatlocation);

    Hope that gives you a couple more ideas. Cheers.
    boB

  • Stonger
    Stonger
    33 Posts

    Re: .click() misses the mark in RFT

    ‏2013-10-11T16:16:08Z  
    • boB
    • ‏2013-10-11T15:17:50Z

    Is there any chance that the Test Object's size is actually bigger than it's clickable area? With what you have tried and with the default click(), they aim for the middle of the object. I have used this in the past to click a certain section of a button:

    // Gets the center point of the object you want to click.
    Point objectlocation = ((GuiTestObject) object).getScreenPoint();
     
    // A bit of math to help replace the mouse.
    int math = (object.getVisibleArea().height/ 8) * 3;
     
    // Making a new point to click on.
    Point bottomquarter = new Point(objectlocation.x, objectlocation.y + math);
     
    // LowLevelEvent that strings together moving and clicking.
    LowLevelEvent clickatlocation[] = { mouseMove(bottomquarter), delay(250), leftMouseButtonDown(), delay(250), leftMouseButtonUp() };
    getRootTestObject().emitLowLevelEvent(clickatlocation);

    Hope that gives you a couple more ideas. Cheers.
    boB

    I wish I could try this suggestion, but I have just been upgraded to a new machine which runs Windows 7 (I was on Windows XP previously) and my problem magically went away.  .click() is suddenly clicking properly on all objects I have tested so far!

    I guess I will leave this question as unanswered to hopefully foster more suggestions for others who may still be experiencing this problem.

  • NaveenEshwar
    NaveenEshwar
    24 Posts

    Re: .click() misses the mark in RFT

    ‏2014-07-12T21:21:54Z  

    Hi stronger ...

    did you find any solution for this ?? 

  • Sathish804
    Sathish804
    1325 Posts

    Re: .click() misses the mark in RFT

    ‏2014-07-14T11:26:18Z  

    Hi stronger ...

    did you find any solution for this ?? 

    Check your Page resolution is 100% or not.

    What object are you trying to click?

  • NaveenEshwar
    NaveenEshwar
    24 Posts

    Re: .click() misses the mark in RFT

    ‏2014-07-14T12:04:55Z  

    Check your Page resolution is 100% or not.

    What object are you trying to click?

    Hi sathish,

    page resolution is fine.

    the same operation in IE is working and in chrome it misses the click

    the code is 

    TestObject[] links = RootTestObject.getRootTestObject().find(atDescendant(".class","Html.LI","title","Logout"),false);
          ((GuiTestObject) links[0]).click();
           unregister(links);

     

    thanks

  • Sathish804
    Sathish804
    1325 Posts

    Re: .click() misses the mark in RFT

    ‏2014-07-14T12:38:39Z  

    Hi sathish,

    page resolution is fine.

    the same operation in IE is working and in chrome it misses the click

    the code is 

    TestObject[] links = RootTestObject.getRootTestObject().find(atDescendant(".class","Html.LI","title","Logout"),false);
          ((GuiTestObject) links[0]).click();
           unregister(links);

     

    thanks

    Have you checked the number of objects found with your code?

    May be there are more than 1 object found with find method.

  • Stonger
    Stonger
    33 Posts

    Re: .click() misses the mark in RFT

    ‏2014-07-14T13:59:22Z  

    Hi stronger ...

    did you find any solution for this ?? 

    I haven't yet found a solid solution that works every time, but what I have found to sometimes help is to do the following:

     

    GuiTestObject guiObject = // Some action which returns your test object
    Rectangle bounds = (Rectangle) guiObject.getProperty(".bounds");
    guiObject.click(new Point(bounds.width / 2, bounds.height / 2));

     

    The idea here is to try and force it to click in the middle of the object base on its boundaries/dimensions. But I've found that it sometimes still misses the mark, in which case I try it without the division by 2 in one or both of the dimensions. It doesn't always behave how you would expect so it may take a bit of trial and error before getting something that actually clicks your object.

    Updated on 2014-07-14T14:07:21Z at 2014-07-14T14:07:21Z by Stonger
  • NaveenEshwar
    NaveenEshwar
    24 Posts

    Re: .click() misses the mark in RFT

    ‏2014-07-16T11:44:15Z  

    Have you checked the number of objects found with your code?

    May be there are more than 1 object found with find method.

    there is only one object ...

    tried all other means ...

  • NaveenEshwar
    NaveenEshwar
    24 Posts

    Re: .click() misses the mark in RFT

    ‏2014-07-16T11:48:10Z  
    • Stonger
    • ‏2014-07-14T13:59:22Z

    I haven't yet found a solid solution that works every time, but what I have found to sometimes help is to do the following:

     

    GuiTestObject guiObject = // Some action which returns your test object
    Rectangle bounds = (Rectangle) guiObject.getProperty(".bounds");
    guiObject.click(new Point(bounds.width / 2, bounds.height / 2));

     

    The idea here is to try and force it to click in the middle of the object base on its boundaries/dimensions. But I've found that it sometimes still misses the mark, in which case I try it without the division by 2 in one or both of the dimensions. It doesn't always behave how you would expect so it may take a bit of trial and error before getting something that actually clicks your object.

    Hi Stronger,

    thanks for the time.

    no luck for me with approach ..yet let me try spending some time to analyze the pattern

    as of now i am just clicking it using points....

  • Sathish804
    Sathish804
    1325 Posts

    Re: .click() misses the mark in RFT

    ‏2014-07-16T15:08:22Z  

    there is only one object ...

    tried all other means ...

    Please post the object recognition properties of the object when it was found using "find" method.

    Add this line to your code to get properties.

    Sysout(links[0].getProperties().toString());

     

     

  • NaveenEshwar
    NaveenEshwar
    24 Posts

    Re: .click() misses the mark in RFT

    ‏2014-07-21T06:42:18Z  

    Please post the object recognition properties of the object when it was found using "find" method.

    Add this line to your code to get properties.

    Sysout(links[0].getProperties().toString());

     

     

    HI Sathish,

    the below are the properties,

    {title=Logout, .contentText=, .screenTop=5, .title=Logout, .className=fun_logout, .text=, class=fun_logout, .id=, .offsetTop=6, .tag=LI, .xpath=//body/div[@id='topFrame']/div[3]/ul[1]/li[1], .type=, .class=Html.LI, .offsetLeft=1574, .value=0.0, .screenLeft=1558, .offsetWidth=16, .disabled=false, .hasFocus=false, .bounds=java.awt.Rectangle[x=1558,y=66,width=15,height=15], .offsetHeight=16, .innerText=}
     

     

  • Sathish804
    Sathish804
    1325 Posts

    Re: .click() misses the mark in RFT

    ‏2014-07-21T07:10:01Z  

    HI Sathish,

    the below are the properties,

    {title=Logout, .contentText=, .screenTop=5, .title=Logout, .className=fun_logout, .text=, class=fun_logout, .id=, .offsetTop=6, .tag=LI, .xpath=//body/div[@id='topFrame']/div[3]/ul[1]/li[1], .type=, .class=Html.LI, .offsetLeft=1574, .value=0.0, .screenLeft=1558, .offsetWidth=16, .disabled=false, .hasFocus=false, .bounds=java.awt.Rectangle[x=1558,y=66,width=15,height=15], .offsetHeight=16, .innerText=}
     

     

    Hi Try with hover to see whether mouse pointer has been moved correctly or not. The hover point on the object is the same point where click will be preformed. So try to find the exact point where you need to click by trail and error.

     

    TestObject[] links = RootTestObject.getRootTestObject().find(atDescendant(".class","Html.LI","title","Logout"),false);

    ((GuiTestObject) links[0]).hover();

    sleep(1);

          ((GuiTestObject) links[0]).click();
           unregister(links);
  • NaveenEshwar
    NaveenEshwar
    24 Posts

    Re: .click() misses the mark in RFT

    ‏2014-07-21T14:31:33Z  

    Hi Try with hover to see whether mouse pointer has been moved correctly or not. The hover point on the object is the same point where click will be preformed. So try to find the exact point where you need to click by trail and error.

     

    TestObject[] links = RootTestObject.getRootTestObject().find(atDescendant(".class","Html.LI","title","Logout"),false);

    ((GuiTestObject) links[0]).hover();

    sleep(1);

          ((GuiTestObject) links[0]).click();
           unregister(links);

    i have already tried sathish but no luck !!!