Navigation Menu

Skip to content

Commit

Permalink
[java] Skipping PrintPageTest tests for Chrome for now.
Browse files Browse the repository at this point in the history
Chrome needs to run headless and a workaround for this
is needed.
  • Loading branch information
diemol committed Jan 21, 2021
1 parent 5493d43 commit 29ecb67
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 26 deletions.
10 changes: 4 additions & 6 deletions java/client/src/org/openqa/selenium/print/PageMargin.java
Expand Up @@ -17,13 +17,11 @@

package org.openqa.selenium.print;

import org.openqa.selenium.internal.Require;

public class PageMargin {
private double top;
private double bottom;
private double left;
private double right;
private final double top;
private final double bottom;
private final double left;
private final double right;

public PageMargin() {
this.top = 1.0;
Expand Down
6 changes: 2 additions & 4 deletions java/client/src/org/openqa/selenium/print/PageSize.java
Expand Up @@ -18,12 +18,10 @@
package org.openqa.selenium.print;


import org.openqa.selenium.internal.Require;

public class PageSize {

private double height;
private double width;
private final double height;
private final double width;

public PageSize() {
// Initialize with defaults. A4 paper size defaults in cms.
Expand Down
24 changes: 8 additions & 16 deletions java/client/test/org/openqa/selenium/PrintPageTest.java
Expand Up @@ -19,47 +19,39 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assume.assumeTrue;
import static org.openqa.selenium.testing.drivers.Browser.CHROME;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.print.PageSize;
import org.openqa.selenium.print.PrintOptions;
import org.openqa.selenium.testing.Ignore;
import org.openqa.selenium.testing.JUnit4TestBase;
import org.openqa.selenium.testing.NoDriverAfterTest;
import org.openqa.selenium.testing.NoDriverBeforeTest;

public class PrintPageTest extends JUnit4TestBase {
private static final String MAGIC_STRING = "JVBER";
private PrintsPage printer;

@Before
public void setUp() {
System.setProperty("webdriver.chrome.headless", "true");
createNewDriver(new ImmutableCapabilities());
assumeTrue(driver instanceof PrintsPage);
printer = (PrintsPage) driver;
driver.get(pages.printPage);
}

@After
public void tearDown() {
System.clearProperty("webdriver.chrome.headless");
}

// TODO: Skipped for Chrome because it needs to run headless, a workaround for this is needed.
@Test
@NoDriverBeforeTest
@NoDriverAfterTest
@Ignore(value = CHROME)
public void canPrintPage() {
PrintOptions printOptions = new PrintOptions();

Pdf pdf = printer.print(printOptions);
assertThat(pdf.getContent().contains(MAGIC_STRING)).isTrue();
}

// TODO: Skipped for Chrome because it needs to run headless, a workaround for this is needed.
@Test
@NoDriverBeforeTest
@NoDriverAfterTest
@Ignore(value = CHROME)
public void canPrintTwoPages() {
PrintOptions printOptions = new PrintOptions();
printOptions.setPageRanges("1-2");
Expand All @@ -68,9 +60,9 @@ public void canPrintTwoPages() {
assertThat(pdf.getContent().contains(MAGIC_STRING)).isTrue();
}

// TODO: Skipped for Chrome because it needs to run headless, a workaround for this is needed.
@Test
@NoDriverBeforeTest
@NoDriverAfterTest
@Ignore(value = CHROME)
public void canPrintWithValidParams() {
PrintOptions printOptions = new PrintOptions();
PageSize pageSize = new PageSize();
Expand Down

0 comments on commit 29ecb67

Please sign in to comment.