Posts

Showing posts from May, 2019

How to handle calendar or date picker using JavascriptExecutor?

Image
Sometimes it is very difficult to select a particular date in Calendar or Date picker displayed in AUT (Application Under Test). It can be done easily by using JavascriptExecutor by setting the attribute value. Selenium doesn't have any inbuilt method to set attribute value or change anything in the HTML DOM (Document Object Model) structure. That's why we have to take the help of JavascriptExecutor to set the attribute value of a date picker. AUT :   https://www.spicejet.com/  [Spicejet website is taken as Application Under Test] Example : In the below image, we have a "DEPART DATE" calendar where a date [02-05-2019] needs to be selected. On inspecting the "DEPART DATE" web element, we will get the tag name and its attributes [Please see below Image] You can see the value of attribute " value " is " 31-05-2019 " During run time, we can change the attribute value by...