Ranorex provides the possibility to debug code directly in the development environment.
Enable debugging
- In Ranorex Studio, click Enable Debugging in the toolbar or use
Ctrl+F5 - Start your test run as you normally would (for example, via Run).
Set and remove breakpoints
Breakpoints force execution to pause at a specific line of code.
You can add a breakpoint by either:
- Clicking the left margin next to the line, or
- Placing the cursor on the line and selecting Debug > Toggle Breakpoint
A breakpoint appears as a red circle in the margin and highlights the line. Remove it using the same action.
Start a debug run
After setting a breakpoint, the debugger can be started by executing your application as described in the article Run.
The application starts, and Ranorex Studio switches to the Debug Layout, which causes the following menu items to be available from Debugger menu and toolbar:
Debugger actions
These actions are available from the Debug menu and the debugging toolbar:
- Continue: Resume execution until the next breakpoint.
- Stop process: Force the process to stop.
- Step over: Execute the current line without stepping into called methods.
- Step into: Step into the method called on the current line.
- Step out: Finish the current method and return to the caller.
Debugging toolbar items
To skip several lines of code and continue debugging on a specific line, the context menu item Set Current Statement can be chosen by right-clicking on the line and choosing Set Current Statement from the context menu.
You can also hover over variables in code to view values via tooltips.
Inspect state while paused
When execution is paused, you can diagnose the current state using the windows under View > Debug:
- Callstack: Shows the current method call chain.
- Local variables: Shows variables in the current scope, method arguments, and relevant fields/properties.
-
Watch: Lets you evaluate expressions.
- Add expressions via right-click Add, or drag selected expressions from code into the Watch window.
Additionally, to the different views, it’s also possible to diagnose individual objects directly in code using the tool tips that pop up when moving the mouse over them.
Debugging without running Ranorex Studio elevated
Run the debugger without elevating Rx Studio’s permission by disabling Use UiaLauncher to elevate privileges for processes started by tools option under your Settings>Advanced
Result
- Your debugged project runs without uiAccess permissions.
- The code is debuggable, but your test may not be able to interact with applications running with elevated privileges (admin apps).
Troubleshooting: debugging is slow (LowLevelHooksTimeout)
In some environments, debugging may become noticeably slow if certain Visual Studio versions have modified the Windows hook timeout.
Because registry edits can affect the whole machine, apply this only if your IT policy allows it and you understand the impact.