How to print Driver Capabilities for Chrome and Mozilla browsers in Selenium WebDriver| AjAutomation

Published: 07 September 2021
on channel: AJ AUTOMATION
624
8

▶️ In this video , we will see How to print Driver Capabilities for both Chrome and Mozilla in Selenium WebDriver.

▶️ Printing Capabilities in console can help in debugging issues on local and if you have Selenium testcases running on remote m/c like docker , Zalenium.

▶️ It shows us some IMP details like :

acceptInsecureCerts
browserName
browserVersion
chromedriverVersion
platform
timeouts( implicit, pageLoad, script)
------------------------------------------------
▶️ Here we need to use getCapabilities() method from RemoteWebDriver class.

WebDriver driver=new ChromeDriver();

here we can not directly call 'getCapabilities' method as it is undefined for WebDriver type and our driver reference is of WebDriver type.

So you need to cast driver as RemoteWebDriver instance like below and then you would be able to access that method.

((RemoteWebDriver)driver).getCapabilities().toString());
------------------------------------------------
▶️ If we write
RemoteWebDriver driver = new ChromeDriver(); OR
ChromeDriver driver=new ChromeDriver();// all methods from RemoteDriver will be accessible.

then we no need to cast the driver. But as we need to work on multiple browsers , we keep same reference(driver) as WebDriver type so that same can be used to refer ChromeDriver and FirefoxDriver class objects.

▶️ Note: -
RemoteWebDriver implements WebDriver , JavaScriptExecutor, TakeScreenshot interfaces

ChromeDriver extends RemoteWebDriver.
FirefoxDriver extends RemoteWebDriver.

So type of objects will determine the method you can access.


======================================
***************AJ AUTOMATION*************
======================================

🔔 Learn automation from basic !! 🔔

✅ Recent Uploads :=
   • Recent Uploaded Videos  

✅ Selenium series videos Playlist :=
   • Selenium tutorial for beginners - Mos...  

✅ Maven Tool videos playlist :=
   • Maven Tool - Learn Basics To Advanced...  

✅ Java Language Concepts :=
   • Java Language Concepts - By AjAutomation  

✅TestNG Framework Videos:=
   • TestNG Introduction and Why we use Te...  

✅ Become Master in Xpath:=
   • Xpath Introduction  

✅ Protractor series videos playlist :=
   • Let's Learn Protractor - By AjAutomation  


======================================
*************** Thanks for watching !!*************
======================================


⚡️ Keep Learning...Keep Sharing...Keep Growing. ⚡️

#LearnSeleniumInEasyWay #SeleniumWebDriver