Selenium Webdriver: HTML renders differently for Firefox vs. PhantomJS

梦想的初衷 提交于 2019-12-02 05:21:01
Andrew Regan

One quick win is to equalise your window dimensions, as PhantomJS seems to prefer a tall strip rather than a decent rectangle by default.

PhantomJS uses WebKit for rendering, while Firefox uses Gecko, so there's an inevitable possibility of slight differences.

Different PhantomJS versions are also built against different WebKit versions. Apparently PhantomJS 2.x uses WebKit 538.x, which makes it equivalent to Safari 7 or 8. By contrast, my current PhantomJS 1.9.8 uses WebKit 534.34, which is equivalent to Safari 5.

Google determines Safari 5 to be an "old" browser and will therefore potentially render its search pages differently. (I don't think it's likely that JavaScript has failed to run - not unless you've explicitly disabled it.)

So upgrading to PhantomJS 2.x would doubtless reduce rendering differences vs. Firefox.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!