节点上带有 HtmlUnit 的 WebDriver Grid 与节点 CPU 挂钩
我使用 C# 和 Gallio/mbUnit 编写一组非常简单的测试,打开浏览器,导航到 google.com,在搜索框中输入“seleniumhq”,然后单击搜索按钮。
我使用以下命令创建主机:
java -jar \"C:\\selenium-server-standalone-2.15.0.jar\" -role hub -port 4444
使用以下命令创建节点:
java -jar \"C:\selenium-server-standalone-2.15.0.jar\" -角色节点 -hub http://[hostIP]:4444/grid/register -port 5556 -browser browserName=htmlunit,platform=ANY,version=firefox,maxInstances=1
我创建我的 webDriver 实例,我使用:
driver = new RemoteWebDriver("http://localhost:4444/wd/hub", DesiredCapability.HtmlUnitWithJavaScript());
我正在监控我的节点机器,当测试开始时,CPU 仅运行 1 个测试就固定在 99%。我在等待搜索按钮显示时超时...它就在那里,只是不可见,即使在 40 秒后也是如此:
var wait = new WebDriverWait(WebDriver, new TimeSpan(0, 0, 0, 40));
wait.Until(m => m.FindElement(By.Name("btnG")).Displayed);
对于为什么该元素对于 HtmlUnit 始终不可见有什么想法吗?
对于为什么远程节点上的 HtmlUnit 的 CPU 固定在或接近 100% 以及内存峰值高达 800,000K 有什么想法吗?
我复制了相同的测试来创建 10 个相同的测试,如果删除单击搜索按钮代码,则 HtmlUnit 测试需要 65 秒。此测试使用两个节点,每个节点的 DegreeOfParallelism 设置为 10,MaxInstances 设置为 5。当我使用 Chrome 使用相同的参数运行相同的测试时,它们在 35 秒内运行,并且我没有看到 CPU 变得疯狂。有人对此有什么想法吗?根据我读到的内容,HtmlUnit 的速度应该是大约 4 倍。我猜我有一些错误,应该是相当明显的。
感谢所有的帮助和建议。
I am usign C#, with Gallio/mbUnit to write a very simple set of tests that open a browser, navigate to google.com, type 'seleniumhq' in the search box, and click the search button.
I create my host with:
java -jar \"C:\\selenium-server-standalone-2.15.0.jar\" -role hub -port 4444
and my node with:
java -jar \"C:\selenium-server-standalone-2.15.0.jar\" -role node
-hub http://[hostIP]:4444/grid/register -port 5556 -browser browserName=htmlunit,platform=ANY,version=firefox,maxInstances=1
I create my webDriver instance, I use:
driver = new RemoteWebDriver("http://localhost:4444/wd/hub",
DesiredCapabilities.HtmlUnitWithJavaScript());
I am monitoring my node machine and when the test commences, the CPU pegs to 99% with just 1 test running. I get timeouts when waiting for the search button to display... it's there, just not visible, even after 40 seconds:
var wait = new WebDriverWait(WebDriver, new TimeSpan(0, 0, 0, 40));
wait.Until(m => m.FindElement(By.Name("btnG")).Displayed);
Any thoughts on why that element isn't visible for HtmlUnit consistently?
Any thoughts on why the CPU pegs at or near 100% and spikes in memory up to 800,000K for HtmlUnit on a remote node?
I have the copied the same test to create 10 identical tests and if I remove the click search button code, the HtmlUnit tests take 65 seconds. This test is using two nodes, DegreeOfParallelism set at 10, and MaxInstances set at 5 for each node. When I run the same tests with the same paramters with Chrome, they run in 35 seconds and I don't see the CPU going crazy. Anybody have any ideas on this? HtmlUnit is supposed to be about 4x's as fast from what I have read. I am guessing that I have something wrong that should be fairly obvious.
Thanks for all help and suggestions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有点晚了,但是:
要了解 HtmlUnitDriver 正在做什么,请使用
jstack
获取线程转储。您可能会发现它陷入僵局或陷入循环。我遇到了一些僵局&使用较旧的 HtmlUnit 版本存在悬而未决的问题,但最新的 Selenium 服务器版本 (2.31.0) 使用 HtmlUnit 2.11这似乎已经解决了这些问题。
看起来您使用的是 Selenium 2.15,其中包括 HtmlUnit 2.9,这可能是问题所在。
A bit late, but:
To find out what the HtmlUnitDriver is doing, get a thread dump using
jstack <pid>
. You'll probably see that it is deadlocked or stuck in a loop.I've have had some deadlock & hanging issues using older HtmlUnit versions, but the latest Selenium server versions (2.31.0) are using HtmlUnit 2.11 which seems to have resolved these issues.
It looks like you were using Selenium 2.15 which includes HtmlUnit 2.9, which could be the problem.