Skip to content

Commit 8d35e5f

Browse files
committed
Add PrintPage test in root level
1 parent ae2ca16 commit 8d35e5f

File tree

5 files changed

+13
-26
lines changed

5 files changed

+13
-26
lines changed

java/client/src/org/openqa/selenium/BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ java_export(
5757
"//java/client/src/org/openqa/selenium/remote",
5858
"//java/client/src/org/openqa/selenium/safari",
5959
"//java/client/src/org/openqa/selenium/support",
60+
"//java/client/src/org/openqa/selenium/print",
6061
] + CDP_DEPS,
6162
)
6263

java/client/src/org/openqa/selenium/WebDriver.java

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import org.openqa.selenium.logging.LoggingPreferences;
2121
import org.openqa.selenium.logging.Logs;
22+
import org.openqa.selenium.print.PrintOptions;
2223

2324
import java.net.URL;
2425
import java.time.Duration;
@@ -67,6 +68,7 @@ public interface WebDriver extends SearchContext {
6768
*/
6869
void get(String url);
6970

71+
Pdf print(PrintOptions options);
7072
/**
7173
* Get a string representing the current URL that the browser is looking at.
7274
* <p>

java/client/src/org/openqa/selenium/print/BUILD.bazel

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
load("@rules_jvm_external//:defs.bzl", "artifact")
21
load("//java:defs.bzl", "java_library")
32

43
java_library(
54
name = "print",
6-
srcs = glob(["*.java"]),
5+
srcs = glob(["**/*.java"]),
76
visibility = [
8-
"//java/client/src/org/openqa/selenium:__pkg__",
9-
"//java/client/src/org/openqa/selenium/remote:__pkg__",
10-
"//java/client/test/org/openqa/selenium:__subpackages__",
11-
"//java/client/test/org/openqa/selenium/build:__pkg__",
12-
"//java/client/test/org/openqa/selenium/testing/drivers:__pkg__",
7+
"//visibility:public",
138
],
149
deps = [
1510
"//java/client/src/org/openqa/selenium:core",

java/client/test/org/openqa/selenium/firefox/FireFoxPrintCommandTest.java renamed to java/client/test/org/openqa/selenium/PrintPageTest.java

+8-18
Original file line numberDiff line numberDiff line change
@@ -15,40 +15,29 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
package org.openqa.selenium.firefox;
18+
package org.openqa.selenium;
1919

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

22-
import org.junit.After;
23-
import org.junit.Test;
2422
import org.junit.Before;
25-
26-
import org.openqa.selenium.Pdf;
23+
import org.junit.Test;
2724
import org.openqa.selenium.print.PageSize;
2825
import org.openqa.selenium.print.PrintOptions;
2926
import org.openqa.selenium.testing.JUnit4TestBase;
3027

31-
public class FireFoxPrintCommandTest extends JUnit4TestBase {
32-
33-
private FirefoxDriver localDriver = new FirefoxDriver();
28+
public class PrintPageTest extends JUnit4TestBase {
3429
private static String MAGIC_STRING = "JVBER";
3530

3631
@Before
3732
public void setUp() {
38-
localDriver.get(pages.printPage);
39-
}
40-
@After
41-
public void tearDown() {
42-
if (localDriver != null) {
43-
localDriver.quit();
44-
}
33+
driver.get(pages.printPage);
4534
}
4635

4736
@Test
4837
public void canPrintPage() {
4938
PrintOptions printOptions = new PrintOptions();
5039

51-
Pdf pdf = localDriver.print(printOptions);
40+
Pdf pdf = driver.print(printOptions);
5241
assertThat(pdf.getContent().contains(MAGIC_STRING)).isTrue();
5342
}
5443

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

60-
Pdf pdf = localDriver.print(printOptions);
49+
Pdf pdf = driver.print(printOptions);
6150
assertThat(pdf.getContent().contains(MAGIC_STRING)).isTrue();
6251
}
6352

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

74-
Pdf pdf = localDriver.print(printOptions);
63+
Pdf pdf = driver.print(printOptions);
7564
assertThat(pdf.getContent().contains(MAGIC_STRING)).isTrue();
7665
}
66+
7767
}

java/client/test/org/openqa/selenium/firefox/BUILD.bazel

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ LARGE_TESTS = [
55
"FirefoxDriverTest.java",
66
"MarionetteTest.java",
77
"TakesFullPageScreenshotTest.java",
8-
"FireFoxPrintCommandTest.java",
98
]
109

1110
java_test_suite(

0 commit comments

Comments
 (0)