Page 1 of 2

How to configured and use WebDriver in the Ranorex?

Posted: Thu Jun 25, 2020 3:04 pm
by Valeriy777
Hi,

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

Thanks.

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

Posted: Mon Jun 29, 2020 6:23 am
by odklizec
Hi,

Webdriver integration is described in Ranorex user guide, available here:
https://www.ranorex.com/help/latest/int ... tegration/

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

Posted: Tue Jun 30, 2020 3:05 pm
by Valeriy777
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!

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

Posted: Tue Jun 30, 2020 4:03 pm
by Valeriy777
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?

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

Posted: Tue Jun 30, 2020 10:10 pm
by N612
You can switch between local web and a selenium endpoint via the endpoint panel. Select "Local host" for local web.

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

Posted: Wed Jul 01, 2020 7:25 am
by Valeriy777
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

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

Posted: Wed Jul 01, 2020 12:27 pm
by McTurtle
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

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

Posted: Thu Jul 02, 2020 8:47 am
by Valeriy777
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

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

Posted: Thu Jul 02, 2020 9:13 am
by odklizec
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?

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

Posted: Fri Jul 03, 2020 7:38 am
by Valeriy777
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'.)

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

Posted: Fri Jul 03, 2020 7:42 am
by odklizec
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.

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

Posted: Fri Jul 03, 2020 7:48 am
by Valeriy777
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']"

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

Posted: Fri Jul 03, 2020 7:54 am
by odklizec
Hi,

Could you please post entire project? You can zip it via menu Tools >> Compress solution and open folder menu.

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

Posted: Fri Jul 03, 2020 8:03 am
by Valeriy777
Please see attachment

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

Posted: Fri Jul 03, 2020 9:03 am
by odklizec
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.