Handling nested web elements. We have seen some toggle buttons, check boxes etc which are nested by some other tags like label etc. Normal selenium command “Click” will not be able to click on toggle sometimes, as it will find it is not clickable.
Complete area of some web elements like button, checkbox etc are not clickable. We need to click on specific part of element to perform action. Selenium might fail here sometimes. In this case also “Js” is very useful.
Scrolling is also a big problem in selenium. Using “Js”, we can scroll by pixels or to the web element.
Handling hidden elements. We can use “JS” to get text or attribute value from hidden web element which cannot be done by normal selenium methods.
Drag and drop issues can be handled using JS.
Object executeScript (String arg0, Object… arg1);
js. executeScript (“arguments . click()”,ele);