使用Java中的selenium驱动程序进行测试,无需打开任何浏览器 [英] Testing with a selenium driver in Java without opening any browser

查看:181
本文介绍了使用Java中的selenium驱动程序进行测试,无需打开任何浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Java中使用selenium chrome驱动程序进行测试。但是不应该打开镀铬窗口。假设这是一个产品,不应该打开任何窗口。

I need to test with selenium chrome driver in Java. But chrome window should't be opened. Assume this a product and no window should be opened.

我也看过这个;
是否可以在Selenium RC中隐藏浏览器?
但我没办法解决。测试应该是独立于操作系统的,我已经尝试过HtmlUnitDriver进行测试而不打开任何窗口,但它有一些问题。当通过id查找组件时,它可能无法通过id找到组件。有些服务器可能会根据浏览器发送组件ID,我不知道应该用什么ID来测试。

I've also looked at this one ; Is it possible to hide the browser in Selenium RC? But no solution for me. The testing should be operating system independent and I've tried HtmlUnitDriver for testing without opening any window but it has some problem. When there is finding components by id, it may not find the component by id. Some servers may send the component id according to browser and I can't know what id I should use to test.

因为我正在尝试使用chrome驱动程序。

Because of that I'm trying to use chrome driver.

有没有办法在不打开镀铬窗口的情况下使用chromedriver或其他方式进行测试而不用Java中的Selenium打开任何窗口?

谢谢!

推荐答案

使用PhantomJS 但是如果在chromedriver中运行它们是必需的并且你有资源,这个博客有一个很好的食谱运行无头硒铬合金。要求您下载以下内容...

Go with PhantomJS but if running them in chromedriver is required and you have the resources, this blog has a good recipe on running headless selenium with chrome. Requiring you to download the following...


  • VirtualBox

  • Vagrant

  • NodeJS

如果您打算实施 Jenkins 或未来的任何其他CI,我强烈建议您使用PhantomJS。

If you plan to implement Jenkins or any other CI in the future, I strongly suggest going with PhantomJS though.

这篇关于使用Java中的selenium驱动程序进行测试,无需打开任何浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆