Focus on a row fail

Ask general questions here.
Ahmad
Posts: 19
Joined: Tue Apr 09, 2019 7:29 am
Location: Berlin

Focus on a row fail

Post by Ahmad » Tue May 28, 2019 10:49 am

Hi All,

I have a table with a large number of rows.
how can I make a focus on a row (which is not shown in the screen) before I make a click on this row?
I tried using focus(), but it did not work.

Thank you in advance for your support.

Regards,
Ahmad

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

Re: Focus on a row fail

Post by odklizec » Tue May 28, 2019 11:11 am

Hi,

Could you please post a Ranorex snapshot (NOT screenshot) of the table in question? Unfortunately, without, at very least, snapshot, there is not much anyone here can do or suggest. The obvious thing, you may try, is EnsureVisible action. If EnsureVisible does not help, then you may eventually need to scroll the table, using table's scroll bar, which may require some code. But without seeing your table (its snapshot), these hints are just wild guesses ;)
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

Ahmad
Posts: 19
Joined: Tue Apr 09, 2019 7:29 am
Location: Berlin

Re: Focus on a row fail

Post by Ahmad » Tue May 28, 2019 11:51 am

Hi Odklizec,

thank you for your replay.
Here is a snapshot of the table and rows.
I tried focus(), EnsureVisible(), select() but they did not work.

Thank you.
Regards,
Ahmad
Attachments
TableRow.rxsnp
(4.62 MiB) Downloaded 8 times

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

Re: Focus on a row fail

Post by odklizec » Tue May 28, 2019 12:09 pm

Hi,

Thanks for the snapshot. Well, if nothing helps, you will most probably have to use code, which would scroll the table, until the row in question is not visible?

A sample code, doing something similar, can be found here:
https://www.ranorex.com/forum/select-an ... 13961.html
Basically, you must pass a repo element to the method from above post. Here is the xpath you can use for table rows, you want to to make visible...

Code: Select all

/form[@automationid='m_MainWindow']/?/?/grip[@automationid='m_Thumb']/container[@caption='Setup']//table/container[@accessiblename='Datenbereich']/row[@accessiblename=$rowName and @visible='True']
Where the rowName variable should be filled via variable (e.g. Zeile 67)

Hope this helps?
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

Ahmad
Posts: 19
Joined: Tue Apr 09, 2019 7:29 am
Location: Berlin

Re: Focus on a row fail

Post by Ahmad » Tue May 28, 2019 1:28 pm

Hi,

thank you for fast replay .
I think the solution with scroll down method should work. but i have a small question:
how can I pass a repo element info to the method from the xpath?

Thank you.
Regards,
Ahmad

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

Re: Focus on a row fail

Post by odklizec » Tue May 28, 2019 1:42 pm

Hi,

You can't create element info from xpath. Element info is a repo-based thing. So you should simply create a repo element with given xpath and then pass that repo element to method. Why do you want to use xpath in code? In my opinion, it's a very bad idea, because this would make your code pretty easy to break and messy. You should always (as much as possible) to pass repo elements to methods.
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

Ahmad
Posts: 19
Joined: Tue Apr 09, 2019 7:29 am
Location: Berlin

Re: Focus on a row fail

Post by Ahmad » Tue May 28, 2019 2:07 pm

odklizec wrote:
Tue May 28, 2019 1:42 pm
Hi,

You can't create element info from xpath. Element info is a repo-based thing. So you should simply create a repo element with given xpath and then pass that repo element to method. Why do you want to use xpath in code? In my opinion, it's a very bad idea, because this would make your code pretty easy to break and messy. You should always (as much as possible) to pass repo elements to methods.
Hi,

thank you very much,
I don't want to use xpath in code, I thought first I must use it.
I tried the solution and it works well. :)

Thank you again very much.
Regards,
Ahmad

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

Re: Focus on a row fail

Post by odklizec » Tue May 28, 2019 2:12 pm

Cool! I'm glad it helped ;)
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