Skip to content

Commit

Permalink
Add PrintPage test in root level
Browse files Browse the repository at this point in the history
  • Loading branch information
raju249 committed Jan 18, 2021
1 parent ae2ca16 commit 8d35e5f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 26 deletions.
1 change: 1 addition & 0 deletions java/client/src/org/openqa/selenium/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ java_export(
"//java/client/src/org/openqa/selenium/remote",
"//java/client/src/org/openqa/selenium/safari",
"//java/client/src/org/openqa/selenium/support",
"//java/client/src/org/openqa/selenium/print",
] + CDP_DEPS,
)

Expand Down
2 changes: 2 additions & 0 deletions java/client/src/org/openqa/selenium/WebDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.openqa.selenium.logging.LoggingPreferences;
import org.openqa.selenium.logging.Logs;
import org.openqa.selenium.print.PrintOptions;

import java.net.URL;
import java.time.Duration;
Expand Down Expand Up @@ -67,6 +68,7 @@ public interface WebDriver extends SearchContext {
*/
void get(String url);

Pdf print(PrintOptions options);
/**
* Get a string representing the current URL that the browser is looking at.
* <p>
Expand Down
9 changes: 2 additions & 7 deletions java/client/src/org/openqa/selenium/print/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
load("@rules_jvm_external//:defs.bzl", "artifact")
load("//java:defs.bzl", "java_library")

java_library(
name = "print",
srcs = glob(["*.java"]),
srcs = glob(["**/*.java"]),
visibility = [
"//java/client/src/org/openqa/selenium:__pkg__",
"//java/client/src/org/openqa/selenium/remote:__pkg__",
"//java/client/test/org/openqa/selenium:__subpackages__",
"//java/client/test/org/openqa/selenium/build:__pkg__",
"//java/client/test/org/openqa/selenium/testing/drivers:__pkg__",
"//visibility:public",
],
deps = [
"//java/client/src/org/openqa/selenium:core",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,29 @@
// specific language governing permissions and limitations
// under the License.

package org.openqa.selenium.firefox;
package org.openqa.selenium;

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.After;
import org.junit.Test;
import org.junit.Before;

import org.openqa.selenium.Pdf;
import org.junit.Test;
import org.openqa.selenium.print.PageSize;
import org.openqa.selenium.print.PrintOptions;
import org.openqa.selenium.testing.JUnit4TestBase;

public class FireFoxPrintCommandTest extends JUnit4TestBase {

private FirefoxDriver localDriver = new FirefoxDriver();
public class PrintPageTest extends JUnit4TestBase {
private static String MAGIC_STRING = "JVBER";

@Before
public void setUp() {
localDriver.get(pages.printPage);
}
@After
public void tearDown() {
if (localDriver != null) {
localDriver.quit();
}
driver.get(pages.printPage);
}

@Test
public void canPrintPage() {
PrintOptions printOptions = new PrintOptions();

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

Expand All @@ -57,7 +46,7 @@ public void canPrintwoPages() {
PrintOptions printOptions = new PrintOptions();
printOptions.setPageRanges(new String[]{"1-2"});

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

Expand All @@ -71,7 +60,8 @@ public void canPrintWithValidParams() {
printOptions.setOrientation(PrintOptions.Orientation.Landscape);
printOptions.setPageSize(pageSize);

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

}
1 change: 0 additions & 1 deletion java/client/test/org/openqa/selenium/firefox/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ LARGE_TESTS = [
"FirefoxDriverTest.java",
"MarionetteTest.java",
"TakesFullPageScreenshotTest.java",
"FireFoxPrintCommandTest.java",
]

java_test_suite(
Expand Down

0 comments on commit 8d35e5f

Please sign in to comment.