How to detect browser type during run-time?

Ask general questions here.
Posts: 10
Joined: Tue May 22, 2018 10:12 pm

How to detect browser type during run-time?

Post by bowang616 » Wed Dec 12, 2018 9:14 pm


What is the best way to detect what browser is currently running Ranorex automation during run-time? For example, I have a recording with some actions that downloads a file from the web page, now the problem I have is each browser (Chrome, Firefox, Edge, IE) has a different way of saving and downloading this file, and all the elements for each browser are different as well, so the actions in the recording don't work with all browsers.

How do I automate, say, if the browser is Chrome, run these actions, or if the browser is Firefox, run these actions, etc. Is there a way, or a feature, or an action that can accomplish this decision making? If not, is there a way to code this in C#? Pseudo code would be:
if (browser == "Chrome")
///run these actions
else if (browser == "Firefox")
///run these actions

Thanks for your time.

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

Re: How to detect browser type during run-time?

Post by odklizec » Thu Dec 13, 2018 9:26 am


In my opinion, your best hope is to use Ranorex conditions and rules. Basically, you should create a number of smartfolders inside your test case, where each smartfolder will represent one browser and contain the module(s) related to that browser. Now each smartfolder should have a condition, enabling the smartfolder (and its content) only if the condition rule is fulfilled. Please follow the user guide for more details regarding conditions and rules: ... ons-rules/

Check also this post, showing an example of TC with conditional smartfolders:
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