Invalid elements in DOM tree

Bug reports.
maese
Posts: 6
Joined: Wed Aug 24, 2016 7:36 am

Invalid elements in DOM tree

Post by maese » Fri Oct 07, 2016 12:55 pm

My test fails on a validate-exists step and the error message says that the element can not be found (Attachment s1.png). The real problem is, that Ranorex sees an invalid table element in the DOM tree (Attachment s2.png). This can be seen with the "Ranorex Element Browser" in the tab ""BROWSER & RESULTS". In the browser all is fine, inspecting the elemtents directly in the browser shows no problems (Attachment s3.png).

The element to validate is contained in a table, which is rendered with JavaScript. After "document ready" the table may be not ready, because it needs some more time to add all event handlers.

A delay or wait step before would solve the problem and the table element is not invalid then. It seems like the Ranorex plugin in the browser causes the problem. The problem does not exists when I test manually.

My theory is, that the Ranorex plugin should not access the DOM tree elements, while JavaScript has not yet finsihed attaching event handlers to the elements.
Is this a known bug?

I'm not share in which browsers the problem occurs. In at least one case the problem was only with Firefox and not happened with Chrome and IE11.

Used versions:
- Ranorex 6.1
- Firefox 49.0.1
- Ranorex Firefox Plugin: Ranorex Automation NG 1.0.3
Attachments
s3.png
In the browser all looks fine
s3.png (40.86 KiB) Viewed 661 times
s2.png
Ranorex sees an invalid tabke element in the DOM tree
s2.png (48.9 KiB) Viewed 661 times
s1.png
Repository Item can not be found
s1.png (47.03 KiB) Viewed 661 times

Vaughan.Douglas
Posts: 250
Joined: Tue Mar 24, 2015 5:05 pm
Location: Des Moines, Iowa, USA

Re: Invalid elements in DOM tree

Post by Vaughan.Douglas » Fri Oct 07, 2016 1:39 pm

I've had similar experiences where it seems like Ranorex tries to do something to an object before it's ready. The curser just goes up to the upper left corner and a context menu displays. I'd start by adding @state='complete' to the RxPath for your root page object. This probably won't fix your problem because of the JavaScript call, but it's good technique.

Then before I validate the existence of something, I usually stick a WaitFor method in there on some parent container.

I agree that adding a hard WAIT is not a good solution because you'll always wait for the specified duration. WaitFor on the other hand waits up to the duration meaning it will move along as soon as the element is available.

A final "trick" I've used is to add a mouse move step in there which basically just slows it down. Sometimes you just need to slow Ranorex down a bit.
Doug Vaughan

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

Re: Invalid elements in DOM tree

Post by odklizec » Fri Oct 07, 2016 1:43 pm

Hi,

WaitFor Exists/NotExist is definitely the way to go. It's the easiest and most reliable way to pause the test execution before the previous action is completed.
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