Page 1 of 1

Invalid elements in DOM tree

Posted: Fri Oct 07, 2016 12:55 pm
by maese
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

Re: Invalid elements in DOM tree

Posted: Fri Oct 07, 2016 1:39 pm
by Vaughan.Douglas
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.

Re: Invalid elements in DOM tree

Posted: Fri Oct 07, 2016 1:43 pm
by odklizec
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.