

For entering the file path, we would need a method to enter text. The Robot class provides various methods for handling mouse and keyboard events.

Invoke method: Now invoke the required method on robot object. Instantiate: A robot class object is needed to invoke its methods. Let's use the Robot class methods to enter the file path.ġ.Import package: Robot class has to import first, to use.Ģ.
SHARP DRIVER 1.13 WINDOWS
Here, pop-up to select file is Desktop Windows appears. So, the user clicks on the Choose File button first to enter the file path to be uploaded. Consider the scenario where a user wants to upload a file. Let us understand the use of Robot class methods with the help of an example on ToolsQa's demo site.

It differs from Selenium which uses the WebDriver API and invokes commands to a browser to perform actions. This class uses native system events to control the mouse and keyboard. What is a Robot class?Īs per the class description, this class is used to generate native system input events. Therefore, to handle such scenarios, the Robot class is used. Whereas for Desktop windows pop-up, no locator exists, and the same can be verified using browser developer tools. The reason being, Actions class methods need WebElement objects to perform actions. One can't use Action class methods to handle keyboard/mouse events on Desktop windows pop-up.
SHARP DRIVER 1.13 DOWNLOAD
To handle such pop-ups we need the Robot class.įor instance, if you are trying to download Email Attachment, Windows pop-up, 'Save Attachment' prompts to specify Download Location, appears. But Windows pop-ups don't have any locators, as they are not part of the webpage, they are native OS pop-ups. We know that to perform any action on a web element, we need a locator for the element. Here, the pop-ups/alerts are Windows pop-ups instead of Webpage pop-ups.
SHARP DRIVER 1.13 HOW TO
