Friday 14 September 2018

How to run Chrome & Firefox Webdriver in Headless mode

Headless Browser! What does it mean.? As name suggests, It is a browser without head.i.e., without GUI. 

Headless Browsers are a kind of simulation programs of real browsers, but without GUI. Having said that, these may not be 100% equal to real browsers as they have its own limitations. Here are few popular headless browsers:

  • Headless Chrome
  • Headless Firefox
  • HtmlUnit Driver
  • PhantomJS
  • SlimmerJS

Headless browsers come with its own Pros & Cons.
Pros:

  • Improves the execution speed,in turn increases the performance.
  • Can be executed on Browser-less setups like Servers(without browsers).
  • Useful while scraping the web.
  • Simulate multiple browser versions on a single machine.

Cons:

  • It doesn't mimic the real user.
  • Debugging is quite difficult.

Below snippet would show you, How to make Chrome & Firefox work in Headless mode.

Friday 7 September 2018

Compare Images in Selenium Test

Visual / UI Validation of web pages across different browsers & devices is very important these days as more and more applications are getting web enabled. And most of the websites are eyeing on 'Responsive Web Design' to create a single website across multiple resolutions.

This type of testing is usually performed manually. However, now you can automate these type of tests to an extent using different image comparison libraries like Thumbnailator, Slenium-Shutterbug, ImageMagick Applitools Eyes etc.

Using these libraries, both Functional Testing & Visual Testing can go hand-in-hand without having to maintain separate set of scripts.
One such example using Image-comparison.jar based on Thumbnailator library is as below:


Steps:


Wednesday 5 September 2018

Capture Full Screenshot in Selenium using Shutterbug


Selenium with the new upgrade 2.0 to 3.* had changed the way it works in the background. Starting with this upgrade, FirefoxDriver has stopped taking the full screenshot. There are many instances where user needs complete screenshot of the web page.
Many teams have worked on it & provided few open source libraries like AShot, ShutterBug etc.

Below code snippet would enable you to get the full screenshot using ShutterBug java library.

STEPS:


Capture Full Screenshot in Selenium using AShot


Selenium with the new upgrade 2.0 to 3.* had changed the way it works in the background. Starting with this upgrade, FirefoxDriver has stopped taking the full screenshot. There are many instances where user needs complete screenshot of the web page.
Many teams have worked on it & provided few open source libraries like AShot, ShutterBug etc.

Below code snippet would enable you to get the full screenshot using AShot java library.

STEPS: