Taking Screenshots using Selenium webdriver

Testing steps:

  1. Load the page using the given URL (Log in | Register (formsscasb.tk))
  2. Select the Sign-Up link
  3. Fill out all the fields and uncheck the checkbox
  4. Click the Create Account button
  5. Take the screenshot
  6. Quit browser

Code:

Script:

public static void main(String[] args) throws Exception {

WebDriverManager.edgedriver().setup();

EdgeOptions options = new EdgeOptions();

options.addArguments(“start-maximized”);

WebDriver driver = new EdgeDriver(options);

driver.get(“https://www.formsscasb.tk/Formsscasb/Formsscasb/checkout.ssp?is=login&loginParam=false&login=T&fragment=login-register#login-register“);

driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));

Thread.sleep(2000);

driver.findElement(By.className(“login-register_login”)).click();

System.out.println(“Title of the Page : “+driver.getTitle());

Thread.sleep(2000);

driver.findElement(By.id(“register-firstname”)).sendKeys(“Tester”);

driver.findElement(By.id(“register-lastname”)).sendKeys(“John”);

driver.findElement(By.id(“register-company”)).sendKeys(“Test House”);

driver.findElement(By.id(“register-email”)).sendKeys(“testhouse@gmail.com“);

driver.findElement(By.id(“register-password”)).sendKeys(“qatester@123”);

driver.findElement(By.id(“register-password2”)).sendKeys(“qatester@123”);

driver.findElement(By.id(“register-emailsubscribe”)).click();

driver.findElement(By.className(“login-register-register-form-submit”)).click();

Thread.sleep(15000);

TakesScreenshot ts = (TakesScreenshot) driver;

File file = ts.getScreenshotAs(OutputType.FILE);

FileUtils.copyFile(file, new File(“./ScreenShots/Image1.png”));

driver.quit();

Leave a comment

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