Ranorex Driver is a service tool based on a Ranorex test suite solution and is used for the automation of desktop applications.
It exposes a W3C WebDriver interface on top of Ranorex runtime. As a result, Ranorex Driver works with tests that are written using the Selenium framework.
Installation and Setup
Ranorex Driver is available as a standalone installation C:\Program Files (x86)Ranorex.
It was intended to be a lightweight application, it does not install any Ranorex runtime libraries and integrates with Ranorex Studio on the machine instead (it uses Runtime provided by Ranorex Studio).
Ranorex Driver installation is straightforward, follow these steps to complete it:
-
Select the location of the Ranorex Studio bin folder, the default port for having Ranorex Driver, and click Next
-
Click Install
-
After the installation is completed, you can select to run Ranorex Driver automatically by checking the box at the bottom of the window, and click Finish
Auto Run Ranorex Drive: If you do not check this option, you need to start the service manually. Find the RanorexDriver.exe in the bin folder of Ranorex Studio as stated above
Ranorex Driver Status
Once Ranorex Driver launches, you can find its tray icon in the Windows toolbar, right-click the icon to check the current status of Ranorex Driver:
If the status is ‘Connected’ you can start performing your first tests.
Ranorex Driver Configuration
Edit the config.toml file to update the IP address or port. This file is created during Ranorex Service installation and is placed in C:ProgramDataRanorex Driver directory.
When the value for either of them is changed, save the file, and restart Ranorex Service to apply changes.
from selenium import webdriver from selenium.webdriver.common.keys import Keys driver = webdriver.Remote(“http://127.0.0.1:7993”, { “browserName”: “Ranorex”, “rx:app”: “Calc”, “rx:args”: “”, “rx:force”: True, “rx:whitelist”: [“Calculator”, “Calc”, “CalculatorApp”]}) print(“Calc application opened: ” + driver.title) button2 = driver.find_element_by_xpath(“/winapp//button[@automationid=’num2Button’]”) print(“Calc button 2 get handle”) button2.click() print(“Calc button 2 clicked”) driver.find_element_by_xpath(“/winapp//button[@automationid=’num1Button’]”).click() print(“Calc button 1 clicked”) driver.find_element_by_xpath(“/winapp//button[@automationid=’multiplyButton’]”).click() print(“Calc button * clicked”) driver.find_element_by_xpath(“/winapp//button[@automationid=’num2Button’]”).click() print(“Calc button 2 clicked”) driver.find_element_by_xpath(“/form”).send_keys(“=”) print(“Calc sent key =”) result = driver.find_element_by_xpath(“/winapp//text[@automationid=’NormalOutput’]”).text print(“result: ” + result) driver.close()
Example
The API can be invoked after Ranorex Driver is up and ready. The following example shows you how to use Selenium Python client, Ranorex Driver, and the Windows Calculator application to perform your first test.
-
Python Installation
Make sure you have Python installed on your machine. If not, download and install it from Python Downloads.
-
Selenium Installation
After you install Python, open cmd, and install the Selenium module using pip tool:pip install selenium
Automation with Ranorex Driver and Selenium
-
Create the calc_test.py file in any location and add the content of the following link Ranorex Driver and Selenium Automation.
-
Save the file and open cmd tool. Navigate to the location where you saved calc_test.py and invoke command:
python test_calc.py
The Calculator application should have started and the automation should run.
Supported WebDriver APICommands
As mentioned previously, Ranorex Driver does not support all Webdriver API. Below, is the list of the supported functionalities:
- New Session
- Delete Session
- Status
- Set Timeouts
- Get Title
- Find Element
- Get Element Attribute
- Get Element Text
- Get Element Tag Name
- Is Element Enabled
- Element Clear
- Take Element Screenshot
Visit WebDriver for more information about the above API. Note that API on the website is described in the context of plain REST API requests but these equivalent methods can be found in the Selenium Python module as well.