How to find a sting in browser page using headless driver

Best practices, code snippets for common functionality, examples, and guidelines.
mmahra
Posts: 37
Joined: Wed Feb 26, 2020 2:17 pm

How to find a sting in browser page using headless driver

Post by mmahra » Thu Mar 05, 2020 1:05 pm

Hello,

I am trying to validate a string in page using Ranorex Studio
I am able to run it on normal browser using either Key press (Ctrl+F) or click on chrome menu and select find then type my string,
Both ways are not working on headless with below error, is there a workaround for that?
Last edited by mmahra on Thu Mar 19, 2020 11:13 am, edited 1 time in total.

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

Re: How to find a sting in browser page using headless driver

Post by odklizec » Thu Mar 05, 2020 1:11 pm

Hi,

As before, please post a Ranorex snapshot of the problematic element (parent/main form). My guess is that the xpath is simply not compatible? I'm not quite sure if Create Snapshot action is applicable with webdriver integration? Just give it a try ;)
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

mmahra
Posts: 37
Joined: Wed Feb 26, 2020 2:17 pm

Re: How to find a sting in browser page using headless driver

Post by mmahra » Thu Mar 05, 2020 1:28 pm

Where exactly do I create the snapshot?

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

Re: How to find a sting in browser page using headless driver

Post by odklizec » Thu Mar 05, 2020 1:39 pm

Hi,

Add new action (Create Snapshot) right before the failing action. And make sure the action is connected with repo element, ideally DOM element.
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

mmahra
Posts: 37
Joined: Wed Feb 26, 2020 2:17 pm

Re: How to find a sting in browser page using headless driver

Post by mmahra » Thu Mar 05, 2020 5:03 pm

Unfortunately, fixing the XPath this time is not working for headless browser.

User avatar
Vega
Certified Professional
Certified Professional
Posts: 222
Joined: Mon Jul 11, 2016 2:15 pm

Re: How to find a sting in browser page using headless driver

Post by Vega » Thu Mar 05, 2020 7:35 pm

Are you able to create a Ranorex snapshot of the repo element from the working machine? If needed you can learn to create a snapshot below:

https://www.ranorex.com/help/latest/han ... -snapshot/

I assume you are using a webdriver endpoint in order to test via a headless browser. The thing that sticks out to me is that your RX path is trying to find a form object:

Code: Select all

/form[@title>'Jive Admin Console : Logging']
The problem is that a webdriver endpoint cannot interact with anything other an a web element (WebDriver limitation). This object appears to be outside of the DOM which is why the webdriver cannot find it. A form element is most likely a browser control (not an actual web element) but it is hard to say without seeing a Ranorex snapshot. This is something that Ranorex can see no problem because it can recognize a lot more than just web object, but webdriver can only see items within the DOM (without the use of Selenium API).

So yeah if you are able to share a snapshot, it should tell us a lot.

hope this helps

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

Re: How to find a sting in browser page using headless driver

Post by odklizec » Fri Mar 06, 2020 8:42 am

Hi,

Vega is absolutely right! Webdriver cannot handle elements outside DOM. I completely missed that the failing xpath starts with form ;) So the only way around is to eliminate all steps involving elements outside DOM. Or not to use headless/webdriver approach ;)
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

mmahra
Posts: 37
Joined: Wed Feb 26, 2020 2:17 pm

Re: How to find a sting in browser page using headless driver

Post by mmahra » Fri Mar 06, 2020 10:44 am

Thanks vega

mmahra
Posts: 37
Joined: Wed Feb 26, 2020 2:17 pm

Re: How to find a sting in browser page using headless driver

Post by mmahra » Fri Mar 06, 2020 10:45 am

Thanks Pavel, I will consider your recommendations.