问题描述
我需要在 Java 中使用 selenium chrome 驱动程序进行测试.但不应打开 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.
有没有办法在不打开 chrome 窗口的情况下使用 chromedriver,或者在 Java 中不打开任何 Selenium 窗口的情况下进行测试?
谢谢!
推荐答案
使用 PhantomJS 但是如果需要在 chromedriver 中运行它们并且你有资源,这个博客有一个很好的秘诀running headless selenium with chrome.要求您下载以下...
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...
- 虚拟盒子
- 流浪者
- 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 驱动程序进行测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!