Dynamic list

Ask general questions here.
SanMan
Posts: 210
Joined: Tue Apr 13, 2010 9:59 am

Dynamic list

Post by SanMan » Mon Jun 18, 2018 12:00 pm

Hi again,

Before I could "freeze the list" by disabling the javascript and then read the list.

Now they did made some updates to code and now when I disable the javascript, only the items in view are shown so cannot read a constantly updating list anymore.

If I have the number of item in the list, what is the best way to read all the items? Can I use EnsureVisible(); or is the some other better way? I tried to MoveTo(), but it won't work if the item is not available.

Or should I scroll the list & disable javascript and read the items in view and then again enable javascript and scroll the list further?

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

Re: Dynamic list

Post by odklizec » Mon Jun 18, 2018 12:45 pm

Hi,

It sounds as if the list is now lazy-loaded, which means that only the items visible in view are loaded. It's good programming practice, to save the memory and speed-up the GUI loading. On the other hand, it's hell for us TA guys ;)

I'm afraid, EnsureVisible will most probably not help you, because the items you are looking for are not even loaded in memory. So your only hope to access them, is to use page Up/Down or Up/Down arrow keys. Eventually, you should be able to click the scroll bar buttons? In any case, it would require some code, which will help you to check, if the items you are looking for were loaded or not. Unfortunately, it's hard to suggest something more detailed without seeing your app under test.
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

SanMan
Posts: 210
Joined: Tue Apr 13, 2010 9:59 am

Re: Dynamic list

Post by SanMan » Mon Jun 18, 2018 1:33 pm

Thank you for your answer. Case is just like you described :)

I tried to make a repository item with variable and it worked fine with the visible items. But when need to scroll down the list, the index will get "broken".

I try to use page Up/Down or Up/Down arrow keys.

I cannot "select/highlight" the list item without mouse :(

So should I read the visible items, then scroll the list to see more list items and then read them?

SanMan
Posts: 210
Joined: Tue Apr 13, 2010 9:59 am

Re: Dynamic list

Post by SanMan » Mon Jun 18, 2018 1:41 pm

"Unfortunately, it's hard to suggest something more detailed without seeing your app under test"

I created a support ticket for this case. Because there seems not to be a generic resolve to this problem.

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

Re: Dynamic list

Post by odklizec » Mon Jun 18, 2018 1:44 pm

SanMan wrote:So should I read the visible items, then scroll the list to see more list items and then read them?
Yep, it's probably your only hope.

Here is the code I'm using in one my tests, where list of items is lazy loaded. scheduleInfoElement is a repo element with xpath containing a name of item (passed via variable) I need to select. Basically, it first scrolls the list to the first list item (using Home button), then it scrolls the list items (one by one) by Down key, until the scheduleInfoElement is found.

Code: Select all

		public void ScrollToScheduling(RepoItemInfo scheduleInfoElement)
		{
			SpanTag scheduleElement=null;
			Keyboard.PrepareFocus(repo.RPDashboard_Dom.ListBox.ListBox_LST);
			Keyboard.Press(System.Windows.Forms.Keys.Home, Keyboard.DefaultScanCode, Keyboard.DefaultKeyPressTime, 1, true);
			while (!scheduleInfoElement.Exists(5000, out scheduleElement))
			{
				Keyboard.Press(System.Windows.Forms.Keys.Down, Keyboard.DefaultScanCode, Keyboard.DefaultKeyPressTime, 1, true);
				Delay.Duration(20);
			}
			Keyboard.Press(System.Windows.Forms.Keys.Enter, Keyboard.DefaultScanCode, Keyboard.DefaultKeyPressTime, 1, true);
			Delay.Duration(20);
		}
The xpath behind the scheduleInfoElement looks like this:

Code: Select all

./body/div[@id~'listBox' and @visible='True']/div[@id~'innerListBox' and @class~'jqx-listbox']//div[@class='jqx-listitem-element']/span[@innertext~$scheduleName and @class~'selected']
If the keyboard-based actions are not an option in your AUT, you will most probably have to use mouse clicks? 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