Page 1 of 1

How to detect browser type during run-time?

Posted: Wed Dec 12, 2018 9:14 pm
by bowang616
Hello,

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.

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

Posted: Thu Dec 13, 2018 9:26 am
by odklizec
Hi,

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:
https://www.ranorex.com/help/latest/ran ... ons-rules/

Check also this post, showing an example of TC with conditional smartfolders:
run-recording-module-based-on-get-value-t12999.html