click on text of element

Best practices, code snippets for common functionality, examples, and guidelines.
IvanT
Posts: 37
Joined: Wed Feb 06, 2019 8:00 pm

click on text of element

Post by IvanT » Thu Nov 14, 2019 8:07 pm

how to click on text of element? i tried Location.CenterLeft, but it didn't help. may be ranorex has a specific command? :?: :?: :?: :?:

User avatar
mayo
Posts: 22
Joined: Fri Dec 28, 2018 7:42 pm

Re: click on text of element

Post by mayo » Thu Nov 14, 2019 9:38 pm

Hello!

If you are simply trying to click on an element then I recommend using the Ranorex recording feature:

https://www.ranorex.com/help/latest/ran ... ng-a-test/

If you are using code I believe it should be mouse.click();. You can also right-click actions in the recording module and view the code!

Cheers

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 6184
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: click on text of element

Post by odklizec » Thu Nov 14, 2019 10:51 pm

Hi,

Could you please upload a Ranorex snapshot (NOT screenshot) of the problematic element? Usually, it should be enough to click in Center of the element. But I guess that your UI is somewhat different and only the text itself is active part of element, which must be clicked? Unfortunately, without seeing, at very least, snapshot, it’s impossible to suggest something reliable.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

IvanT
Posts: 37
Joined: Wed Feb 06, 2019 8:00 pm

Re: click on text of element

Post by IvanT » Tue Nov 19, 2019 5:38 pm

Here it is
Attachments
TextOfElement.rxsnp
(3.17 MiB) Downloaded 10 times

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 6184
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: click on text of element

Post by odklizec » Wed Nov 20, 2019 8:28 am

Hi,

Exactly what I thought. The tree item boundary, simply mimics the whole tree list area, which makes the items virtually unclickable.
TreeItem_boundary.png
TreeItem_boundary.png (43.86 KiB) Viewed 275 times
Well, I think that your only hope is to add the entire tree to GDI capture list, refresh the spy and hope that GDI capture extracts all tree items texts to RawTexts. Then you should be able to click exactly on individual tree item texts. Hope this helps?
TreeElement_Text.png
TreeElement_Text.png (25.39 KiB) Viewed 278 times
BTW, I'm not sure if the problem with large surrounding area is caused by the tree implementation or a bug in Ranorex. I would definitely consult this issue with Ranorex folks, via support form available here https://www.ranorex.com/support-query/
On second look, it looks like a Ranorex bug, because Client Rectangle of selected tree item appears to have correct dimensions, especially height (20px). So it must be something Delphi-implementation related?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration