Selenium Webdriver: HTML renders differently for Firefox vs. PhantomJS

后端 未结 1 434
清歌不尽
清歌不尽 2021-01-23 15:51

I am using Selenium Webdriver in Node JS to do a Google search. When I set the browser as Firefox on my local machine, the Google results page renders as expected; it\'s the sam

相关标签:
1条回答
  • 2021-01-23 16:15

    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.

    0 讨论(0)
提交回复
热议问题