本文介绍了HtmlUnitDriver(HtmlUnit)和GhostDriver(PhantomJS)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在选择(有关原因,请阅读下文).


(read below for why).


Update: a bit more detail on PhantomJS versions, from my other answer.

Like Safari, PhantomJS uses WebKit for rendering (e.g. Firefox uses Gecko)

Different PhantomJS versions are built against different WebKit versions. PhantomJS 2.x uses WebKit 538.x, which makes it equivalent to Safari 7 or 8. whereas PhantomJS 1.9.8 uses WebKit 534.34, which is equivalent to Safari 5.

This may be an issue for you, since Google determines Safari 5 to be an "old" browser and will therefore potentially render its search pages differently.

So ensuring you use PhantomJS 2.x can reduce the rendering differences that a lot of people report vs. desktop browsers.


Another interesting possibility is SlimerJS. However, I've not got it to work reliably enough yet.

I've never had reliability issues with either HtmlUnitDriver or PhantomJSDriver (the only annoyance one was a HttpClient 4.5 / HtmlUnit 2.17 incompatibility issue).

(In answer to the comment about modifying HTTP requests, I'd personally recommend sticking to the WebDriver API and use a proxy like BrowserMob to mutate requests and responses rather than taking advantage of browser-specific features.)

All in all, I'd advise against creating a tool or process that forces users to choose one browser over another. If possible, allow them to configure or override. For the majority of cases I'd plump for PhantomJS, as it won't let you down. However, the performance of HtmlUnit should be considered for the simplest pages.

See also (perhaps): http://www.guru99.com/selenium-with-htmlunit-driver-phantomjs.html and https://www.quora.com/Software-Testing/How-does-PhantomJS-compare-to-Selenium

这篇关于HtmlUnitDriver(HtmlUnit)和GhostDriver(PhantomJS)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 09:25
查看更多