Spy tool finds web DOM multiple times?

Ask general questions here.
Ethan
Posts: 10
Joined: Mon Aug 08, 2016 12:09 pm

Spy tool finds web DOM multiple times?

Post by Ethan » Fri Mar 29, 2019 1:19 pm

Hi!

If I start Chrome and navigate to https://www.ranorex.com/blog/ and then in the Spy tool enter this RxPath: "/dom[@caption~'^(?i:software automation)' and @path~'(?i:/blog)']" Spy finds the DOM 4 times:
Spy.png
Spy.png (19.88 KiB) Viewed 214 times
When I hightlight in Spy 2 of the references highlights the Chrome browser, but 2 highlights my Slack-application. I have also seen the same behaviour for Visual Studio Code (Spy seems to think the DOM is present there).

What is going in? Why does it find 2 different references to Chrome and references that highligts non relevant applications. This kills performance, if a RxPath containing "//" it can take 40-80 seconds for Spy to find the element. If close Slack/VSC it is faster, but why does Spy "find" the same DOM multiple times? Has anyone seen this?

Using Ranorex 9.0.

Best regards,

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

Re: Spy tool finds web DOM multiple times?

Post by odklizec » Fri Mar 29, 2019 1:39 pm

Hi,

It’s caused by shadow DOMs. Check this post for a solution...
domain-name-problem-t13656.html#p53592
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

Ethan
Posts: 10
Joined: Mon Aug 08, 2016 12:09 pm

Re: Spy tool finds web DOM multiple times?

Post by Ethan » Fri Mar 29, 2019 2:01 pm

Hi again,

I had to turn of 'Enable JS-based RanorXpath evaluation' after Ranorex 9.0 installation due to other reasons (it failed to resolve the ChildIndex-property in my code when the option was activated).

I tried checking for visability, but that doesn't help. They are all visible:
The attachment Spy2.png is no longer available
The only way I see at the moment is to go by @processname... it seems to do the trick.
Spy2.png
Spy2.png (20.33 KiB) Viewed 206 times
Although it will be some work for me to actually implement this in a nice way into my large existing codebase/repo.

Regards,

User avatar
Support Team
Site Admin
Site Admin
Posts: 11957
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Spy tool finds web DOM multiple times?

Post by Support Team » Fri Mar 29, 2019 7:19 pm

Hi Ethan,

I believe you are experiencing a known Chrome/Electron application issue that has been resolved in Ranorex 8.3.3 and will be part of Ranorex 9.0.1 (soon to be released). To confirm if this is the issue you are experiencing, look at each dom element and see if the browser attribute is showing other applications like in the screenshot below.

1.png
1.png (2.79 KiB) Viewed 199 times

If you are experiencing this bug, you can use one of the below options: I hope this helps!

Regards,
Ned
.
Image

Ethan
Posts: 10
Joined: Mon Aug 08, 2016 12:09 pm

Re: Spy tool finds web DOM multiple times?

Post by Ethan » Mon Apr 01, 2019 10:04 am

Correct, Browser says for example:
Spy4.png
Spy4.png (3.98 KiB) Viewed 170 times
The best I can do is to include @Visible='True', that filters out those not from Chrome, but that still gives me 2 DOMs for Chrome?
Spy5.png
Spy5.png (40.88 KiB) Viewed 170 times
Best regards,

User avatar
Support Team
Site Admin
Site Admin
Posts: 11957
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Spy tool finds web DOM multiple times?

Post by Support Team » Mon Apr 01, 2019 9:03 pm

Hi Ethan,

Whitelisting Chrome should resolve this issue, were you able to try this? Alternatively, you can use Ranorex 8.3.3 or wait for Ranorex 9.0.1 to be released (which contain the bugfix for this issue).

Regards,
Ned
.
Image

Ethan
Posts: 10
Joined: Mon Aug 08, 2016 12:09 pm

Re: Spy tool finds web DOM multiple times?

Post by Ethan » Tue Apr 02, 2019 9:34 am

Yes, thanks for that tip. Note that I use a setup of C#/SpecFlow/NUnit/Ranorex API with a element repo created from Spy (that is, I'm not using Ranorex Studio).

I basically added:

Configuration.Current.Plugins.Win32.WhitelistedProcesses = new string[] { "chrome" };

I have not measured anything yet, but I feel this change increased performance when I run tests on my local machine (Windows 10), where I have alot of windows/applictions opened and the same DOM appeared many times in Spy.

When I deployed the code to a Windows Server 2012 (where the actual testjob run) it failed to find Chrome/DOM when the whitelist was applied, but I haven't had time to investigate this. It is not as crucial there either, since Chrome is the only opend application on that desktop so performance is better there. It's on my local machine everything that can increase performance/reduce element finding times is crucial.

Thanks.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11957
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Spy tool finds web DOM multiple times?

Post by Support Team » Tue Apr 02, 2019 7:26 pm

Since you are using code only, try the below. This will help determine if the whitelisting feature is working on your machine. From my local testing, before whitelisting, there are three Chrome doms when only one is opened (others are from Slack and Skype). After whitelisting, it is reporting one (the correct one).

Code: Select all

IList<WebDocument> chromeDoms;

//Print total Chrome doms (before whitelisting)
chromeDoms = Host.Local.Find<WebDocument>("/dom[@browsername='Chrome']");
Report.Info("Total Doms (before whitelisting): " + chromeDoms.Count);

//Add to Whitelist
Ranorex.Core.Configuration.Current.Plugins.Win32.WhitelistedProcesses = new string[]{"chrome"};

//Print total Chrome doms (after whitelisting)
chromeDoms = Host.Local.Find<WebDocument>("/dom[@browsername='Chrome']");
Report.Info("Total Doms (after whitelisting): " + chromeDoms.Count);
Hope this helps!

Cheers,
Ned
.
Image

Ethan
Posts: 10
Joined: Mon Aug 08, 2016 12:09 pm

Re: Spy tool finds web DOM multiple times?

Post by Ethan » Fri Apr 05, 2019 10:29 pm

Yes, works fine and speeds up test exection on my development machine! Thanx....