which Brwoser is currently active?

Class library usage, coding and language questions.
thecrazykaktus
Posts: 13
Joined: Wed Feb 19, 2014 12:24 pm

which Brwoser is currently active?

Post by thecrazykaktus » Tue May 06, 2014 10:52 am

Hi people,


can any one tell me how I can check which Browser is currently active?
I want to check if just the IE or Firefox is active.

How can i do that?

Thanks.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: which Brwoser is currently active?

Post by Support Team » Wed May 07, 2014 9:08 am

Hello thecrazykaktus,

You can for example use the "Get Value" action as shown in the image below.
GetBrowserName.jpg
GetBrowserName.jpg (22.4 KiB) Viewed 764 times
Another way to check the browser is using the WebDocument class.
Please take a look at the sample code below.
WebDocument browser = repo.YourRepoItem.AbsoluteBasePath.ToString();

if(browser.BrowserName.Equals("IE"))
{
	Report.Info("IE is active");
}
else if(browser.BrowserName.Equals("Mozilla"))
{
	Report.Info("FF is active");
}
Regards,
Bernhard
.
Image

thecrazykaktus
Posts: 13
Joined: Wed Feb 19, 2014 12:24 pm

Re: which Brwoser is currently active?

Post by thecrazykaktus » Wed May 07, 2014 12:10 pm

Thanks, it works fine!