Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2016, Glib Briia <a href="mailto:glib.briia@assertthat.com">Glib Briia</a>
* Distributed under the terms of the MIT License
*/

package com.assertthat.selenium_shutterbug.core;

import com.assertthat.selenium_shutterbug.utils.web.Browser;
import com.assertthat.selenium_shutterbug.utils.web.Coordinates;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedCondition;

import java.util.function.Function;

public class Configurations {
/**
* by default Shutterbug sets java.awt.headless=true
* to avoid exception "Could not initialize class sun.awt.X11GraphicsEnvironment"
* Method is to delete already set property
*/
public Configurations headless(boolean isHeadless) {
if (!isHeadless) {
System.clearProperty("java.awt.headless");
}
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ private Shutterbug() {

}

static {
System.setProperty("java.awt.headless", "true");
}

/**
* Make screenshot of the viewport only.
* To be used when screenshotting the page
Expand Down Expand Up @@ -452,4 +456,8 @@ public static PageSnapshot shootFrame(WebDriver driver, String frameId) {
WebElement frame = driver.findElement(By.id(frameId));
return shootFrame(driver, frame, CaptureElement.VIEWPORT, true);
}

public static Configurations configure() {
return new Configurations();
}
}