While doing automation we come across the scenario where our script dont run as expected and we need to show someone what is happening , so that time we need to record our script.
So, that thing we can easily do with the ATUTestRecorder library.
Step 1:-
Download ATUTestRecorder library from here
Step 2:-
Right click on project> Go to build path > Configure build path
Step 3:-
Go to Add External jars and select the downloaded jar file
Step 4:-
Click on Apply and close
this will add that Jar file into your project path.
By refreshing on Refrence libraries you can see this jar file.
Step 5:-
write a code to record and stop the script.
ATUTestRecorder record = new ATUTestRecorder("E://Recording", "fb", false); record.start();
here you can use Date and time name to save this file, i have used simple name "fb" for easy understanding
This class will take 3 parameters ( 1 file location to save this file , 2nd name of the file , 3 rd is to save background audio)
to Stop recording,
record.stop();
Here i have sample class i have created one script which will record signup script of the facebook.
package facebook; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.support.ui.Select; import atu.testrecorder.ATUTestRecorder; import atu.testrecorder.exceptions.ATUTestRecorderException; public class facebook { public static void main(String[] args) throws ATUTestRecorderException { System.setProperty("webdriver.chrome.driver","C:\\Users\\5558\\eclipse-workspace\\chromedriver.exe"); WebDriver driver = new ChromeDriver(); ATUTestRecorder record = new ATUTestRecorder("E://Recording", "fb", false); record.start(); driver.navigate().to("https://www.facebook.com"); driver.findElement(By.xpath(".//*[@id='u_0_j']")).sendKeys("sam"); driver.findElement(By.name("lastname")).sendKeys("jani"); driver.findElement(By.id("u_0_o")).sendKeys("sam123@yahoo.com"); driver.findElement(By.name("reg_passwd__")).sendKeys("dixit1234"); Select sel = new Select(driver.findElement(By.name("birthday_day"))); sel.selectByValue("24"); Select month= new Select(driver.findElement(By.name("birthday_month"))); month.selectByIndex(8); Select year = new Select(driver.findElement(By.name("birthday_year"))); year.selectByVisibleText("1997"); driver.findElement(By.xpath(".//*[@id='u_0_a']")).click(); driver.findElement(By.xpath(".//*[@id='u_0_11']")).click(); driver.findElement(By.xpath(".//*[@id='u_0_r']")).sendKeys("sam123@yahoo.com"); driver.findElement(By.xpath(".//*[@id='u_0_11']")).click(); record.stop(); driver.close(); } }
No comments:
Post a Comment