Page 1 of 1

Select an item from scroll able web table

Posted: Mon May 13, 2019 3:51 pm
by Langrisser
Hello there,

I am currently writing a web test [Ranorex 9] under chrome to remove a user from a table:

I want to remove a User called 'Dummy User'. To remove the user I need to select him at first step. And here is my little problem:
My repo item for the table only has visible entries in it(like for 1 til Alison). See the attached rxsnp file.
tableissue.rxsnp
Can you tell how I can reach the entry for 'Dummy user' to select this specific user?
Thanks in advance!

Re: Select an item from scroll able web table

Posted: Mon May 13, 2019 7:43 pm
by Vega
Well there are a few ways to go about this depending on your AUT. If you have coders available on your team, you can loop trying to find the name you are looking for and if it is not found, scroll and search the new names that are now visible. Rinse and repeat until your specified name is found.

If the list is in a fixed order, you could utilize recording modules and IF conditions to test your scenario. So for example if the list is always in the same order and we know it takes 10 scroll actions to reach the name you are looking for, then you can have a specific module which scrolls the correct number of times to the specified name.

So let's say you are looking for the name David and it takes 5 scrolls from the top of the list to make the name David visible. Here is how it would go:
  • Data source has the value 'David' which is the name you are looking for
  • You have a recording module which scrolls exactly 5 times to find the name David, performs the needed actions and then scrolls back to the top of the list. (optional) We want to scroll back to the top so you always start in the same spot if you are doing more searches afterwards
  • Then you would place this recording module in a test container (testcase or smart folder) and set an IF condition to only execute the container if the data source value is equal to 'David'
form1.png
It does not have to be structured exactly like the example above, but this should point you in the right direction. So as you can see, each name would have its own recording to both scroll to the specified name and act on it.

Hope this helps

Re: Select an item from scroll able web table

Posted: Tue May 14, 2019 2:39 pm
by odklizec
Hi,

I'm dealing with similar lazy-loaded lists/tables, by using 'while' loop and Down or PageDown shortcuts. If Down/PageDown does not work with your table, you will probably have to mouse click the scrollbar? Here is an example of code I'm using in my projects:

Code: Select all

public void ScrollToElement(RepoItemInfo repoItemToFind, Adapter listBox)
	{
		SpanTag foundElement=null;
		Keyboard.PrepareFocus(listBox);
		Keyboard.Press(System.Windows.Forms.Keys.Home, Keyboard.DefaultScanCode, Keyboard.DefaultKeyPressTime, 1, true);
		while (!repoItemToFind.Exists(5000, out foundElement))
		{
			Keyboard.Press(System.Windows.Forms.Keys.Down, Keyboard.DefaultScanCode, Keyboard.DefaultKeyPressTime, 1, true);
			Delay.Duration(20);
		}
//		foundElement.EnsureVisible();
//		foundElement.Click();
		Keyboard.Press(System.Windows.Forms.Keys.Enter, Keyboard.DefaultScanCode, Keyboard.DefaultKeyPressTime, 1, true);
		Delay.Duration(20);
	}
	
That is the 'easy' part ;) Now the real problem is, that the very last item is always outside the visible area of table, yet, the item is marked as visible=true! So in case the dummy item, you are looking for, is at the very last table position, the mouse click may fail to click it. And sadly, EnsureVisible is useless here. So you will most probably have to use Enter shortcut, as I'm using it in my sample. Of course, the pre-requisity is, that the item you want to 'enter' is already selected. Otherwise, Enter shortcut may eventually confirm wrong item.
LastItemInvisible.png