Not sure why use headless browser

最后都变了- 提交于 2019-12-04 14:36:50

问题


We just implemented CI without using headless browser, but actual browser's. So once there is new code checked in by development team.Our smoke automation code runs as background process on auto machine and send out results. It evens send across screenshots if any failures. What we did not get is, what is the advantage of using headless browser to above process. We need our smoke scripts to get this coverage. Say submitting a massive form which can run for within 5 minutes with controls like Select, Calendar, Uploaded, etc and not simple load of web page.


回答1:


"Headless browser" is a ambiguous term, in general. People use it to refer to browsers designed to run headlessly but also to refer to a browser that normally requires a real display but is run in a configuration that allows it to run with a virtual display. An instance of the latter would be running Firefox with Xvfb. (The angle I'm taking is descriptive: this is how people talk about browsers that are headless. I'm not talking about whether this is correct or not, which would be a prescriptive angle.)

I don't generally run tests with those browsers designed to run headlessly. Why?

  1. Whenever I compared performance between a headless browser and Chrome, the performance gain was very modest, and this was done naively, without trying to optimize Chrome's setup for speed. (I could imagine having the user data be in ram (/dev/shm) for instance, which I did not try.)

  2. At the end of the day I must certify that my software runs in real browsers used by real people. Normal people don't use browsers designed to be headless to run my software. There are no shortcuts to checking that a web application will work with a specific browser. You have to use the target browser, end of story. Even running the code in browser X version Y is not a guarantee that the code will work in browser X version Z (where Z is different from Y). I've had an application that worked fine in Chrome X-1 and Chrome X+1 but crashed badly in Chrome X (where X is some version number I cannot remember right now). Nothing else than testing in Chrome X revealed this. Whatever a headless browser is based on, it is not a substitute for testing in the actual browser your application is targeting.

  3. Conversely, the headless browser can have quirks of its own that do not show up in other browsers. I recently had to figure out why PhantomJS was behaving differently from Firefox or Chrome when it came to dealing with font subtleties. The time spent figuring out quirks that users won't encounter because they don't use headless browsers could be spent figuring out quirks that users will encounter when they use the browsers that people normally use.

I'm not saying there's no good use for browsers designed to run headlessly, but for testing, I pass.

I do run "headful" browsers headlessly when I run local tests. I don't want the test window to show up on my desktop unless I really need it.




回答2:


headless browsers are relatively faster as it does not require any GUI or plugin to be loaded. Whole execution, i.e. loading of browser to closing of browser happens on memory. It does not require any executable to be worked. It can be used mainly for functional testing where you do not have to test on particular browser and make sure that functionality works fine. Mainly used for smoke testing.




回答3:


Headless browsers are usually used to workaround the absence of a real display on machines with no display hardware and no physical input devices.

If you can fire up a real browser on a real display, stick to it.

Though, one of the things that, for instance, Xvfb can make easier - is:

it can be used to test whether clients work correctly at depths or screen sizes that are rarely supported by hardware.




回答4:


I've still never found headless browsing to be consistent, nor valuable to what I need to get accomplished. You can accomplish anything you need to just fine using a real browser.

As far as advantages go, the only advantage that headless browsing gives, is the ability to test on machines that don't have a display.




回答5:


Some will say that using headless tests will be quicker but the facts state that the difference isn't that big. Also, for debugging purposes it is way easier to use a normal browser.



来源:https://stackoverflow.com/questions/32332608/not-sure-why-use-headless-browser

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