Consider a simple DefaultSelenium object

考虑一个简单的DefaultSelenium对象

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.

现在,我的服务器在启动时在命令行中设置了-forcedBrowserMode“*firefox”选项。但是,我有两个不同的批处理文件来启动服务器,一个在firefox中强制执行,一个被迫IE。顺便说一句,-forcedBrowserMode重写实例化java对象中的设置。

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:

问题来自java,我似乎无法找到一种方法来确定我的DefaultSelenium对象在哪个浏览器上运行……我在想:

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.

我需要知道,因为使用GWT web应用程序,要单击按钮,需要根据浏览器进行不同的操作。此外,您可能还想知道为什么我甚至使用-forcedBrowserMode,因为这样我就可以使用自定义的安装firefox/ie安装来进行测试。

Thanks in advance for help!

谢谢你的帮助!

1 个解决方案

#1


1

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:

我认为您可以通过执行一些JavaScript来获得浏览器,例如验证导航器。userAgent或任何特定于浏览器的对象,例如document.defaultView将在IE中为null,而在FF中为null,类似如下:

DefaultSelenium sel = ...
String res = sel.getEval("document.defaultView ? false : true");
boolean isIE = "true".equals(res);

更多相关文章

  1. 如何在命令中传递对象参数?
  2. JavaScript 面向对象编程,严格过程的标准化编程法,目前为止最好的
  3. JAVA复习3 Java类和对象
  4. java对象判断是否为空工具类
  5. 【阿里云】Java面向对象开发课程笔记(十六)——抽象类

随机推荐

  1. 文件上传js打开文件管理器过滤只显示指定
  2. 单击链接中的复选框会导致以下链接——我
  3. HTML5 windows和iframe之间传递消息
  4. HTML5视频标签使用时注意事项
  5. html5中点击按钮,改变按钮状态效果样式
  6. 我得到一个警告坏js小提琴配置
  7. 选择父母没有某个类的所有元素(使用'.not()'
  8. 采用 append 添加的html input无法获得值
  9. 使用ui.router如何让一个控制器成为另一
  10. Js/Html/Css 我好像写了个奇怪的东西