在不打开任何浏览器的情况下使用 Java 中的 selenium 驱动程序进行测试

2023-06-27Java开发问题
15

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

问题描述

我需要在 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 驱动程序进行测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

如何使用 JAVA 向 COM PORT 发送数据?
How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)...
2024-08-25 Java开发问题
21

如何使报表页面方向更改为“rtl"?
How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)...
2024-08-25 Java开发问题
19

在 Eclipse 项目中使用西里尔文 .properties 文件
Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)...
2024-08-25 Java开发问题
18

有没有办法在 Java 中检测 RTL 语言?
Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)...
2024-08-25 Java开发问题
11

如何在 Java 中从 DB 加载资源包消息?
How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)...
2024-08-25 Java开发问题
13

如何更改 Java 中的默认语言环境设置以使其保持一致?
How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)...
2024-08-25 Java开发问题
13