How to use Robot Class in Selenium Web-driver and What it is?

Posted by

Welcome to softwaretestingsensei platform of learning Hub for beginners Selenium Tutorials, In this session, we are going to discuss that how to use Robot class in Selenium Web-driver and what it is. Also, you can see our videos on youtube which have many subscribers with the help of the professionals from

What is Robot Class in JAVA?

Robot class is a special class in Java which will allow us to perform multiple tasks based on user scripts needs or according to requirement in suncraft scripting. In today session we are going to describe a very simple script piece for beginners which will help to give quick start to play with robot class.

  1. import java.awt.Robot;
  2. import java.awt.event.KeyEvent;
  3. import org.openqa.selenium.By;
  4. import org.openqa.selenium.Keys;
  5. import org.openqa.selenium.WebDriver;
  6. import org.openqa.selenium.firefox.FirefoxDriver;
  7. import org.openqa.selenium.interactions.Actions;
  8. import org.testng.annotations.Test;
  9. public class robotclasssession
  10. {
  11. public void robotclasssession_test() throws Exception
  12. {
  13. WebDriver driver=new FirefoxDriver();
  14. driver.manage().window().maximize();
  15. driver.get(“”);
  16. driver.findElement(“email”)).sendKeys(“type your email here for which you are looking
  17. for in testing”);
  18. driver.findElement(“pass”)).sendKeys(“type password here against your id”);
  19. Robot robot_var=new Robot();
  20. robot_var.keyPress(KeyEvent.VK_ENTER);
  21. robot_var.keyRelease(KeyEvent.VK_ENTER);
  22. }
  23. }

Leave a Reply

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