Level7

Webdriver Listeners in Selenium | WebDriverEventListener

Webdriver Listeners in Selenium | WebDriverEventListener

Level7, Selenium
Webdriver Listeners in Selenium : Event listener in WebDriver helps to tack event those we trigger and by using these we could get a better idea of sequential order of actions . Listeners are  helpful for logging and exception section. Suppose you are trying to track exception and the same time wants to take screenshot. Instead of hard-coding logging requests all over the place, we can leverage an event listener to give us the information we want If you think, Listeners are only useful in logging then you are wrong, it more helpful on pre and post steps of a action in selenium webdriver. Selenium provide WebDriverEventListener interface for listening event in selenium, WebDriverEventListener Interface provide methods, which covers most of the actions (not all) in selenium we
Robot Class in Selenium

Robot Class in Selenium

Level7, Selenium
Robot Class in Selenium : Robot Class is available under java.awt.package, Robot class is a Java class which helps the Java developer to emulate the Mouse and Keyboard like actual user, also robot class helps to take screenshot of the desktop Some platforms require special privileges or extensions to access low-level input control. If the current platform configuration does not allow input control, an AWTException will be thrown when trying to construct Robot objects. So, we need to use either AutoIT or Robot class in Selenium Webdriver to interact the Windows Dialog boxes like upload and download.   Use of Robot Class in Selenium: Robot class emulates real user in front of the computer Using Robot Class we can handle keyboard and mouse events in Selenium. Robot ...
Exceptions in Webdriver

Exceptions in Webdriver

Level7, Selenium
In this tutorial, we  will discuss about what kind of exception we will get in selenium webdriver while executing the automation scripts. An exception is an infallible statement; it will always tell you why something has gone wrong in the code.   It may not always be easy to understand the exception, but it does always tell the information about the what is wrong in the code.   One of the good things in selenium is while looking into the exception we will come to know what went wrong as the exception names will give some what clear picture for the error which we will face.   Below are some of the Exceptions which we will see while automating the applications: NoSuchElementException NoSuchFrameException NoSuchWindowException ElementNotVisibleEx
JavaScript Executor in Selenium

JavaScript Executor in Selenium

Level7, Selenium
As JavaScript Executor is an interface so we cannot create an object to this, for this we will type caste to driver object using below syntax:   JavascriptExecutor js = (JavascriptExecutor)driver; js.executeScript(javaScript, arguments); Now we will see some of the examples below that how we can use JavaScriptExecutor to execute the JavaScript to interact with the web elements.   1. How to enter value into textbox: JavascriptExecutor js = (JavascriptExecutor)driver; js.executeScript("document.getElementById('email').value='[email protected]'");   2. How to click a button: JavascriptExecutor js = (JavascriptExecutor)driver; js.executeScript("document.querySelector('#enterimg').click()");   3. How to refresh a window: JavascriptExecutor js = (Javascri...