views:

104

answers:

1

Consider a simple DefaultSelenium object

DefaultSelenium sel = new 
      DefaultSelenium("http://localhost:8080/myapp",4444,"*iexplore","/myAppLevel1");

Now my server is set with the option of -forcedBrowserMode "*firefox" in the command line when I start it up. However, I have 2 different batch files to start the Server, one forced in firefox, one forced to IE. FYI, the -forcedBrowserMode overrides the settings within of the instantiated java object.

The problem is from java, I can't seem to find a way to determine which browser my DefaultSelenium object is running on... I was thinking something like:

sel.getBrowserName();

But nothing like that exists. Are there any other creative ways of doing this?

I need to know because with a GWT web application, to click on a button you need to do it differently based on the browser. As well, you may wonder why I even use the -forcedBrowserMode, because then I can use custom setup firefox/ie installs to test on.

Thanks in advance for help!

+1  A: 

I think that you can get the browser by executing some JavaScript, for example verify navigator.userAgent or any browser specific object, for example document.defaultView will be null in IE and not null in FF, something like this:

DefaultSelenium sel = ...
String res = sel.getEval("document.defaultView ? false : true");
boolean isIE = "true".equals(res);
ZloiAdun
This worked perfectly, thanks!
__nv__