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 themarketingheaven.com.
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.
- import java.awt.Robot;
- import java.awt.event.KeyEvent;
- import org.openqa.selenium.By;
- import org.openqa.selenium.Keys;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.firefox.FirefoxDriver;
- import org.openqa.selenium.interactions.Actions;
- import org.testng.annotations.Test;
- public class robotclasssession
- public void robotclasssession_test() throws Exception
- WebDriver driver=new FirefoxDriver();
- driver.findElement(By.id(“email”)).sendKeys(“type your email here for which you are looking
- for in testing”);
- driver.findElement(By.id(“pass”)).sendKeys(“type password here against your id”);
- Robot robot_var=new Robot();