Test Cases on User’s Timeline:
Manual Testing
May 01, 2021
package demopackage;
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.*;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class ScreenshotExample {
public static void main(String[] args) throws IOException {
System.setProperty("webdriver.chrome.driver", "C:\\Work\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://www.facebook.com");
File src = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(src,new File("C:\\Work\\screenshot.png"));
}
}
package demopackage;
import java.util.Iterator;
import java.util.Set;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class WindowsExample {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver", "C:\\Work\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://www.google.com/intl/en-GB/gmail/about/#");
System.out.println(driver.getTitle());
driver.findElement(By.xpath("//ul[@class='h-c-header__cta-list header__nav--ltr']//a[contains(@class,'h-c-header__nav-li-link')][contains(text(),'Sign in')]")).click();
Set ids = driver.getWindowHandles();
Iterator it = ids.iterator();
String parentid = it.next();
String childid = it.next();
driver.switchTo().window(childid);
System.out.println(driver.getTitle());
driver.switchTo().window(parentid);
System.out.println(driver.getTitle());
driver.quit();
}
}
Defect Life Cycle |