How to configured and use WebDriver in the Ranorex?

Best practices, code snippets for common functionality, examples, and guidelines.
Valeriy777
Posts: 19
Joined: Wed Jun 24, 2020 1:15 pm

How to configured and use WebDriver in the Ranorex?

Post by Valeriy777 » Thu Jun 25, 2020 3:04 pm

Hi,

How to can I configure and use Ranorex for the tests using WebDriver?

Thanks.

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

Re: How to configured and use WebDriver in the Ranorex?

Post by odklizec » Mon Jun 29, 2020 6:23 am

Hi,

Webdriver integration is described in Ranorex user guide, available here:
https://www.ranorex.com/help/latest/int ... tegration/
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

Valeriy777
Posts: 19
Joined: Wed Jun 24, 2020 1:15 pm

Re: How to configured and use WebDriver in the Ranorex?

Post by Valeriy777 » Tue Jun 30, 2020 3:05 pm

Thank you.

I followed the Ranorex guide and completed all steps.
Now I created a new project and try to test with Selenium but can't.

1) I saved and then launched a simple script that types text to the input field (I used the Ranorex Forum for testing).
2) This script works well with Ranorex.
3) When I tried to execute this script with Selenium WebDriver I got the error "Failed to found the item".
- So item can be found with Ranorex, but can't be found with Selenium
4) I inspected the repository and determined strange behavior: the path to the input field isn't appropriate to the existing path.
That the full path to the input field:

/form[@title~'^Test\ Automation\ for\ GUI\ T']/container[@accessiblerole='Grouping']/container[1]/element[@accessiblerole='None']/container[@accessiblename~'^Test\ Automation\ for\ GUI\ T']/element[1]/element/element[@accessiblerole='None']/element[1]/element[@accessiblerole='None']/element[@accessiblerole='None']/element[@accessiblerole='None']/element[2]/?/?/text[@accessiblename='Search Ranorex ...']

As we can see - the path ends with the tag: //text,
but the true path equals to '//div[@class='input-group']/input' and should be ends with '//input'. In addition, Ranorex Selocity totally does not found the '//text' path!

Valeriy777
Posts: 19
Joined: Wed Jun 24, 2020 1:15 pm

Re: How to configured and use WebDriver in the Ranorex?

Post by Valeriy777 » Tue Jun 30, 2020 4:03 pm

I understood the reason - I switched between desktop and Selenium regimes, but can't back to Web regime.
How I can back to the Web regime?
Why do not work the Selenium regime?

User avatar
N612
Posts: 135
Joined: Mon Jul 11, 2016 4:01 pm

Re: How to configured and use WebDriver in the Ranorex?

Post by N612 » Tue Jun 30, 2020 10:10 pm

You can switch between local web and a selenium endpoint via the endpoint panel. Select "Local host" for local web.

Valeriy777
Posts: 19
Joined: Wed Jun 24, 2020 1:15 pm

Re: How to configured and use WebDriver in the Ranorex?

Post by Valeriy777 » Wed Jul 01, 2020 7:25 am

N612 wrote:
Tue Jun 30, 2020 10:10 pm
You can switch between local web and a selenium endpoint via the endpoint panel. Select "Local host" for local web.
Thanks,
but endpoint panel contains only Selenium and Desktop endpoints

McTurtle
Posts: 297
Joined: Thu Feb 23, 2017 10:37 am
Location: Benedikt, Slovenia

Re: How to configured and use WebDriver in the Ranorex?

Post by McTurtle » Wed Jul 01, 2020 12:27 pm

Hello Valeriy777,

The RanoreXPath "/form[@title~'^Test\ Automation\ for\ GUI\ T']/..." is not a dom path. It is the browser form. This happens if the browser is not instrumented. Have you instrumented the browser? If you are trying to track a browser which was open with webdriver, then the Ranorex plugin for that browser will not work. Do you get the same RanoreXPath if you open the browser manually?

Regards,
McTurtle

Valeriy777
Posts: 19
Joined: Wed Jun 24, 2020 1:15 pm

Re: How to configured and use WebDriver in the Ranorex?

Post by Valeriy777 » Thu Jul 02, 2020 8:47 am

McTurtle wrote:
Wed Jul 01, 2020 12:27 pm

The RanoreXPath "/form[@title~'^Test\ Automation\ for\ GUI\ T']/..." is not a dom path. It is the browser form. This happens if the browser is not instrumented. Have you instrumented the browser? If you are trying to track a browser which was open with webdriver, then the Ranorex plugin for that browser will not work. Do you get the same RanoreXPath if you open the browser manually?

Regards,
McTurtle
I executed the following step:

1) I created a new project
2) Then I chose the Recording1 module and press Record button
3) I created a simple script that set the text to the input field
4) I checked this "project" and all works well
5) In the next step, I created new endpoint with Selenium (connection is successful)
6) As a result, I try to launch the script (with Selenium endpoint) and nothing works - I got the "Filed to find element" exception.
And this is the main issue - I need to use WebDriver in the Ranorex project

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

Re: How to configured and use WebDriver in the Ranorex?

Post by odklizec » Thu Jul 02, 2020 9:13 am

Hi,

As McTurtle pointed out, xpath starting with "form" is not a DOM-based xpath. And although form-based xpath can be used in Ranorex, Selenium will not be able to find element behind this xpath. Selenium Webdriver works only with DOM-based xpaths!

The reason why Ranorex recorded "form" and not "dom" xpath is most probably not installed, corrupted or disabled Ranorex plugin in given browser. Could you please try to track the problematic element with Ranorex Spy and eventually create a snapshot (not screenshot) and post it here?
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

Valeriy777
Posts: 19
Joined: Wed Jun 24, 2020 1:15 pm

Re: How to configured and use WebDriver in the Ranorex?

Post by Valeriy777 » Fri Jul 03, 2020 7:38 am

odklizec wrote:
Thu Jul 02, 2020 9:13 am
Hi,

As McTurtle pointed out, xpath starting with "form" is not a DOM-based xpath. And although form-based xpath can be used in Ranorex, Selenium will not be able to find element behind this xpath. Selenium Webdriver works only with DOM-based xpaths!

The reason why Ranorex recorded "form" and not "dom" xpath is most probably not installed, corrupted or disabled Ranorex plugin in given browser. Could you please try to track the problematic element with Ranorex Spy and eventually create a snapshot (not screenshot) and post it here?
Thanks.
This helps, - the repository now use DOM-based path (".//div[@class='input-group']/input[@type='text']"), and all works well with Ranorex endpoint.
But I still can't use the Selenium endpoint.
So, my question didn't change:

How to configured and use WebDriner in the Ranorex?

- I have the success Selenium endpoint connection,
- I have the simple script, that clicks by path ".//div[@class='input-group']/input[@type='text']"
- All works well with Ranorex endpoint
- Nothing work with Selenium endpoint (Failed to find item 'MyTest3Repository.TestAutomationForGUITestingRanore.SearchRanorex'.)

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

Re: How to configured and use WebDriver in the Ranorex?

Post by odklizec » Fri Jul 03, 2020 7:42 am

Hi,
And what exactly is wrong with Selenium endpoint? In your last post, you mentioned that Selenium endpoint is created and connected. So you can run the test, but it fails somewhere? In this case, we need to know exact error message. Ideally, post entire Ranorex report. Thanks.
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

Valeriy777
Posts: 19
Joined: Wed Jun 24, 2020 1:15 pm

Re: How to configured and use WebDriver in the Ranorex?

Post by Valeriy777 » Fri Jul 03, 2020 7:48 am

odklizec wrote:
Fri Jul 03, 2020 7:42 am
Hi,
And what exactly is wrong with Selenium endpoint? In your last post, you mentioned that Selenium endpoint is created and connected. So you can run the test, but it fails somewhere? In this case, we need to know exact error message. Ideally, post entire Ranorex report. Thanks.
Error message:

Failed to find item 'MyTest3Repository.TestAutomationForGUITestingRanore.SearchRanorex'

SearchRanorex full path = "/dom[@domain='www.ranorex.com']//div[@class='input-group']/input[@type='text']"

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

Re: How to configured and use WebDriver in the Ranorex?

Post by odklizec » Fri Jul 03, 2020 7:54 am

Hi,

Could you please post entire project? You can zip it via menu Tools >> Compress solution and open folder menu.
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

Valeriy777
Posts: 19
Joined: Wed Jun 24, 2020 1:15 pm

Re: How to configured and use WebDriver in the Ranorex?

Post by Valeriy777 » Fri Jul 03, 2020 8:03 am

Please see attachment
You do not have the required permissions to view the files attached to this post.

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

Re: How to configured and use WebDriver in the Ranorex?

Post by odklizec » Fri Jul 03, 2020 9:03 am

Hi,

Well, Selenium works for me once there is added OpenBrowser action ;) Have you tried to add OpenBrowser action? The thing is, that you are trying to access DOM (and its elements) while there is no webpage loaded ;) Also, please try your test, with recording steps instead of jumping straight into code. User code is a nice and useful thing, but you should always try first steps with recording actions.
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