Locators | Description |
---|---|
toLeftOf() | Element located to the left of specified element. |
toRightOf() | Element located to the right of the specified element. |
above() | Element located above with respect to the specified element. |
below() | Element located below with respect to the specified element. |
near() | Element is at most 50 pixels far away from the specified element. The pixel value can be modified. |
public void test_ChromeWebElementScreenshot() throws Exception
{
driver.navigate().to("https://www.google.co.in/");
WebElement logo = driver.findElement(By.xpath("//div[@id='hplogo']"));
File file = logo.getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(file, new File("./target/GoogleLogo.png"));
}
public void test_ChromeWebPageScreenshot() throws Exception
{
driver.navigate().to("https://www.google.co.in");
File file = ((ChromeDriver) driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(file, new File("./target/GoogleHomePage.png"));
}
public void test_FirefoxFullWebPageScreenshot() throws Exception
{
driver.navigate().to("https://www.selenium.dev/");
File file = ((FirefoxDriver) driver).getFullPageScreenshotAs(OutputType.FILE);
FileUtils.copyFile(file, new File("./target/SeleniumDevFullPageCapture.png"));
}
chromeDriver.switchTo().newWindow(WindowType.WINDOW);
chromeDriver.switchTo().newWindow(WindowType.TAB);
chromeDriver.manage().window().minimize();
chromeDriver.manage().window().fullscreen();