Adding Browser Extentions with Selenium WebDriver

When Selenium WebDriver launch a browser , it creates a new profile or options set with browser’s default features.This launched browser does not contain addons or extentions.In everytime we need to add on , which addon or extention we want to use.

Chrome

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addExtensions( new File( "/path/to/extension.crx" )) ;
driver = new ChromeDriver(chromeOptions);

Firefox

FirefoxProfile profile = new FirefoxProfile() ; 
profile.addExtension( new File( "/path/to/addon.xpi" )) ; 
FirefoxOptions firefoxOptions = new FirefoxOptions() ; 
firefoxOptions.setProfile(profile) ; 
FirefoxDriver driver = new FirefoxDriver(firefoxOptions) ;

What's happening inside of WebDriver's engine bonnet ?

To drive a car , you need to have a licence plate.Nobody wants to mechanical engineering deggree or asks diffucult questions about how engine works ? However , if you want to create admirable test automations , you need to understand what’s happening behind the scene.

Selenium Web Driver briefly working with 3 steps.

  • Using JSON Wire Protocol(also known as Client API) takes our commands and sends them to browser specific drivers(GeckoDriver , ChromeDriver etc.).
  • These commands converting to browser’s native API and sending HTTP request
  • Then driver listens commands results from HTTP server and sends them back to Selenium

Install All Selenium WebDrivers with One Command

Did you ever want to install or upgrade all Selenium WebDrivers using one line commmand? On windows you can do it with a Chocolately.Chocolatey is a package manager for windows and yummy way to software installation.

Firstly , you need to install chocolately.To do it , open command prompt as an administrator then write this lines.

@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

If installation is success , now you can install drivers

choco install selenium-all-drivers 

List of installed Web Drivers

  • selenium-opera-driver
  • selenium-ie-driver
  • selenium-edge-driver
  • selenium-all-drivers
  • selenium-gecko-driver
  • selenium-chrome-driver

All Selenium Web Drivers will be installed on under “C:\tools\selenium” directory.Don’t forget to add this path as “System Environments Variable”

Upgrade

Upgrading is similar to installation , just change the install variable as upgrade.

choco upgrade selenium-all-drivers

Pull the wires of Chrome with Puppeteer

Everybody knows that , Chrome is market leader and its developer tools are better than other browsers’.It is useful for software developers and software testers.Honestly ; I’m using Mozilla Firefox more than 10 years ,but Chrome is heading straight for the top every day.

Last year , Chrome Team announced headless mode. Headless mode allows to us , running Chrome without GUI.Before that , everybody was using PhantomJs for headless test automation.Now we have got the powerful alternative to test and create automations , Puppeteer is an official tool for Chrome Headless by Google Chrome team.With Puppeteer you can use many features of Chrome Dev Tools with Chrome Headless.If it is not tl;dr for you , you can learn more on puppeteer’s GitHub page. Now , let’s get install puppeteer on our machine.

Hello World

Hi all , new post from my new blog in same url.Before that , my blog was on digitalocean and it become very costly for me -cus turkish liras capital lost is increasing and 1$ aprox. 7₺ when i wrote this post :) - .Now i create a new page using github pages.I will share my old and new posts henceforward this new blog.Just stay tune …

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×