Java Robot Class Tutorial | Robot in Java | Robot Class in Selenium WebDriver | Intellipaat

Java Robot Class Tutorial | Robot in Java | Robot Class in Selenium WebDriver | Intellipaat

Hello friend, let’s understand today’s high level agenda. So we’re going to discuss about the Robot class of Java. So here in the agenda. first we will be discussing what is a robot class how to install it and what are the advantages of using the robot and the disadvantages the limitations and what other methods in this robot class So actually robot is used for doing
some mouse and keyboard actions which are not possible with the selenium webdriver So the mouse and keyboard actions which are happening on the Windows applications on your desktop which cannot be handled by the selenium webdriver in such scenarios we can go for the robot class. So not only robot but you can also use
the other tools like sequelly, auto IT webdriver epi But robot is much simpler as compared to other tools. OK. why because robot comes inbuilt with your Java, the JDk so no need of installing any jar files OK. So as we discussed the robot will be used
in a scenario where you can’t automate using selenium webdriver. Now the question comes why we can’t automate with selenium webdriver because in such scenarios
you can’t find the properties of those elements web elements or desktop elements you can say windows elements. So as you can’t inspect the properties so
you can’t automate them. So in such scenarios such cases we can use robot class methods. Now coming to the installation as we discussed. No need of installing any robot jar files because it comes inbuild with the JDk so you see here No extra installations are needed. So it comes with the JDK package as
Java is a platform independent even robot is also platform independent. So here as we discuss just not robot is used to automate the keyboard and mouse actions. Also it would be helpful in uploading a file
window handlinks a pop up handlings downloading the files, in such scenarios. We will be using this robot As it has some advantages. Also it has some limitations. The disadvantages like as it can automate the keyboard and mouse actions. If I change the screen or if I move to some
other applications the same actions will be performed on the new application as well. So that is one of the limitation in this robot class where it is not considering on which it is not capturing the actions or
not performing the actions on the required application. So whichever application is active on that application the actions are performed. So this is one of the disadvantage in the
robot class. So if i take care of the application the execution would be in a proper sequence so that you can make a note of it. So to use the methods of the robot class we need to create an object for the class as we view here the class name robot, r is an object new robot And this robot will be imported from
robot.awt package of Java As class has many methods. These are the following methods like keyPress Mousepress, mouseover, keyrelease, mouserelease OK and also you’ll find some methods use like if I want to copy and paste some content if you want to copy and paste as you make a control C, it is actually saved it to the clipboard. Your operating system your system’s clipboard. It is saved. It’s like a clipboard is nothing but like
a buffer to save the content to the clipboard. We will be using this string selection class. OK so this string selection class will copy
will create an object with that object. It copies the content to the clipboard. OK. And from the clipboard as I want to paste
it control V. So from the clipboard we will be using a toolkit class Having a method get DEFAULT toolkit where you have a method again system get system clipboard and set the content. So this method will save the content OK to the system clipboard. So this will just copy it with this is a string
selection. It will just select and copy and this method will help you to paste it on the system clipboard. So anyways we’ll be taking an example over this. The copy pasting content so in that case in that example will just discuss in detail how these classes work and how the actual execution will be taken. Although these all operations you can perform with the keyboard like key press, control keys pressed like control V and also giving as you say control V Control C so the key event is a class. Key event and this is the Action performed on that class. So these are some of the methods which are available under the robot class. So in our next session we’ll see an example how to upload a file and download the files.

1 thought on “Java Robot Class Tutorial | Robot in Java | Robot Class in Selenium WebDriver | Intellipaat”

  1. Got a question on Java Robot? Do write it in the comment and you will get a response immediately by our expert. For Selenium training & certification, call us at US: 1800-216-8930 (Toll Free) or India: +917022374614. You can also write us at [email protected]

Leave a Reply

Your email address will not be published. Required fields are marked *