Ranorex Driver is a lightweight service application based on a Ranorex test suite solution and is used to automate Windows desktop applications.
It exposes a standard W3C WebDriver interface on top of the Ranorex runtime. As a result, Ranorex Driver can be used with tests written using Selenium-based frameworks.
Installation and Setup
Ranorex Driver is available as a standalone installation in the Ranorex Studio installation directory (for example, C:\Program Files (x86)\Ranorex\Studio\Bin).
It is designed to be lightweight. Ranorex Driver itself does not install additional Ranorex runtime libraries. Instead, it integrates with the Ranorex Studio installation on the same machine and uses the runtime provided by Ranorex Studio.
Installation Steps
Ranorex Driver installation is straightforward. Follow these steps to complete it:
-
Run the Ranorex Driver installer, select the location of the Ranorex Studio bin folder, the default Port, and click Next.
- Click Install to start the installation.
-
After the installation completes, you can choose to automatically run Ranorex Driver by selecting the corresponding checkbox and clicking Finish.
Note: If you do not enable auto-start, you must start Ranorex Driver manually, navigate to the Ranorex Studio bin folder, and run RanorexDriver.exe.
Ranorex Driver Status
Once Ranorex Driver is running, a tray icon appears in the Windows notification area. Right-click the icon to see the current status of Ranorex Driver.
If the status is Connected, you can start performing your tests.
Ranorex Driver Configuration
Ranorex Driver stores its network settings (IP address and port) in a config.toml file. This file is created when Ranorex Driver is installed and is stored in the Windows ProgramData folder:
C:\ProgramData\Ranorex Driver\config.toml
To change the IP address or port:
- Open
config.tomlin a text editor with administrative privileges. - Update the IP address and/or port values as needed.
- Save the file.
- Restart Ranorex Driver so the changes take effect.
Example
The Ranorex Driver API can be invoked after Ranorex Driver is installed, configured, and running.
The following sections show how to use the following to perform a simple automated test:
- The Selenium Python client
- Ranorex Driver
- The Ranorex Demo Application
Prerequisites
- Python: Make sure Python is installed and available on your PATH. If not, download and install it from the official Python website.
-
Selenium: Install the Selenium module using pip:
pip install selenium
Connecting to Ranorex Driver (Python example)
The following Python snippet shows how to start a Ranorex Driver session for the Windows Calculator application:
from selenium import webdriver
driver = webdriver.Remote(
"http://127.0.0.1:7993",
{
"browserName": "Ranorex",
"rx:app": "Calc",
"rx:args": "",
"rx:force": True,
"rx:whitelist": ["Calculator", "Calc", "CalculatorApp"],
},
)
When you connect to Ranorex Driver there are a few parameters to set. Review the following:
-
browserName– Must always be "Ranorex". -
rx:app– Path or name of the application to start with the session, e.g., "test.exe" or "Calc". -
rx:args– Command-line arguments for the application. -
rx:force– If True, forces the current session to be aborted and restarted. -
rx:whitelist– List of additional process names to whitelist for the session.
Automating the Ranorex Demo Application with Ranorex Driver and Selenium
Download Ranorex Demo Application and extract the application into any folder of your choice.
The following example performs a simple test in the demo application:
from selenium import webdriver
from selenium.webdriver.common.by import By
import time
options = webdriver.FirefoxOptions()
options.set_capability("browserName", "ranorex")
options.set_capability("rx:app", r"C:\Users\user\Desktop\RxDemoApp.exe") #change this to where you put the demoapp.exe
options.set_capability("rx:args", "")
options.set_capability("rx:force", True)
options.set_capability("rx:whitelist", ["RxDemoApp"])
driver = webdriver.Remote(
command_executor="http://127.0.0.1:7993",
options=options
)
print("Application opened: " + driver.title)
print("Entering name")
driver.find_element(By.XPATH, "/form[@title>'Ranorex Studio Demo Appli']/?/?/tabpage[@index='0' and @controlname='RxTabIntroduction']/?/?/text[@accessiblename='Enter your name']").send_keys("Dave");
time.sleep(0.5)
print("Clicking On Submit")
driver.find_element(By.XPATH, "/form[@title>'Ranorex Studio Demo Appli']/?/?/tabpage[@index='0' and @controlname='RxTabIntroduction']/button[@text='Submit']").click()
time.sleep(0.5)
print("Clicking on Object Identification Tab")
driver.find_element(By.XPATH, "/form[@title>'Ranorex Studio Demo Appli']/?/?/tabpage[@accessiblename='Object identification']").click()
time.sleep(0.5)
print("Clicking on panel 1 button")
driver.find_element(By.XPATH, "/form[@title>'Ranorex Studio Demo Appli']/?/?/tabpage[@index='6' and @controlname='RxTabObject']/?/?/button[@controlname='button3']").click()
time.sleep(0.5)
element = driver.find_element(By.XPATH, "/form[@title>'Ranorex Studio Demo Appli']/?/?/tabpage[@index='6' and @controlname='RxTabObject']/?/?/text[@accessiblerole='Text']")
print("Text On tree like UI Structure area: " + element.text)
#Selenium 4 feature take a screenshot on a specific object
element.screenshot('./screenshot.png')
time.sleep(0.5)
print("Clicking On Clear Button")
clearElement = driver.find_element(By.XPATH, "/form[@title>'Ranorex Studio Demo Appli']/?/?/tabpage[@index='6' and @controlname='RxTabObject']/button[@text='Clear']")
clearElement.click()
#Selenium 4 feature size and rect for position/object location
print(clearElement.rect)
time.sleep(0.5)
driver.close()
- Create the
demo_app_test.pyfile in any location and add the above code. -
Open the Command Prompt. Navigate to the location where you saved
demo_app_test.pyand run:python demo_app_test.py
The demo application should start, and the automation should run.
Supported WebDriver API commands
As mentioned previously, Ranorex Driver does not support the full WebDriver API. The following commands are currently supported:
- 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
For detailed information on these commands, see the W3C WebDriver specification
The specification describes the REST endpoints; equivalent methods are available in Selenium client libraries.