Switch between different browsers

Best practices, code snippets for common functionality, examples, and guidelines.
Rakesh123
Posts: 63
Joined: Thu Oct 28, 2010 2:18 pm

Switch between different browsers

Post by Rakesh123 » Wed Jun 28, 2017 10:43 am

Hi Everyone,

I just wanted to how can we switch from one browser to another using Ranorex?

Thanks,
Rakesh

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

Re: Switch between different browsers

Post by odklizec » Wed Jun 28, 2017 11:15 am

Hi,

Cold you please share a bit more details about what exactly you want to achieve? What do you mean by "switch from one browser to another"? If you want to perform a test in multiple browsers, you should use Data Driven approach, as shown for example here:
https://www.ranorex.com/support/screencasts.html#c3896

And here (click Watch Now):
http://www.ranorex.com/automated-testin ... binar.html
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

Rakesh123
Posts: 63
Joined: Thu Oct 28, 2010 2:18 pm

Re: Switch between different browsers

Post by Rakesh123 » Fri Jun 30, 2017 7:27 am

Hi,

Actually I have the below requirement...

1.Login to IE and do some functionality.
2.Login to chrome and do some functionality
Now same page will be displayed in both the browsers.
3.Now I need to go back to IE and do some functionality
4.Come back to Chrome and do some more functionality

Thanks,
Rakesh

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

Re: Switch between different browsers

Post by odklizec » Fri Jun 30, 2017 8:28 am

Hi,

In this case, all you need to use OpenBrowser action at various places in your test? Eventually, you may need to use Navigate action from "Invoke Action" menu.

Additionally, because you need two browsers running the same time, you may need to add BrowserName attribute to DOM element in repository and you will have to use two sets of xpaths (with two DOMs, one for each browser). Eventually, you can use just one set of xpaths, with one DOM, but then the BrowserName attribute needs to be variabilized and you need to set correct BrowserName variable before accessing specific browser (i.e. Crhome or IE).

You see, typically, we expect that the xpath generated in IE is usable (without change) in other browsers too. But because you will have two browsers running at the same time, you can't use the same xpaths, because Ranorex may find the same repo elements in both browsers. In this unfortunate case, it always use the first one found! So this is why you need to use two sets of xpaths or variabilized BrowseName. Hope this helps?
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