Web - Headless browser (Test automation)
Table of Contents
About
A headless browser is an application/library that emulates a web browser but without a graphical user interface ie (without DOM / without the Web api)
They are the basis to build a web bot.
Usage
- Build a robot
- Taking screenshots of web pages.
- Running automated tests for JavaScript libraries.
- Scraping web sites for data.
- Crawl a SPA (Single-Page Application) and generate pre-rendered content (i.e. SSR (Server-Side Rendering)).
- Automating interaction of web pages:
- form submission,
- UI testing,
- keyboard input, etc.
- Capture a timeline trace of your site to help diagnose performance issues.
List
Library
Browser Driver Library:
- Browser Automation - Selenium - Headless browser - WebDriver / ChromeDriver (automated testing - W3C WebDriver API ) - Selenium/WebDriver focuses on cross-browser automation. Its value proposition is a single standard API that works across all major browsers.
- puppeteer focuses on Chromium; its value proposition is richer functionality and higher reliability.
- PhantomJS – a headless web browser using WebKit layout engine for rendering web pages and JavaScriptCore for executing scripted tests.
- HtmlUnit – a headless browser written in Java (Rhino engine to provide JavaScript and AJAX)
- http://casperjs.org/ based on
- SlimerJS is similar to PhantomJs, except that it runs on top of Gecko, the browser engine of Mozilla Firefox instead
- PhantomJS runs on top of Webkit,
- http://triflejs.org/ API is coded as a port of PhantomJS. Internet Explorer browser that runs on top of the V8 engine
Proxy Script Injection:
- https://github.com/DevExpress/testcafe - TestCafe uses a URL-rewriting proxy which allows it to work without the WebDriver (selenium). This proxy injects the driver script that emulates user actions into the tested page.
Browser
- Firefox – headless mode
Command line
Headless browser command line:
- wget,