Skip to content

Commit 55a8ef0

Browse files
navin772harsha509
andauthored
[java]: docs example for full page screenshot in firefox (SeleniumHQ#2066)
* java docs for full page screenshot in firefox * delete the file after assertion --------- Co-authored-by: Sri Harsha <[email protected]>
1 parent 9c3d182 commit 55a8ef0

File tree

5 files changed

+23
-5
lines changed

5 files changed

+23
-5
lines changed

examples/java/src/test/java/dev/selenium/browsers/FirefoxTest.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
import org.junit.jupiter.api.condition.DisabledOnOs;
1414
import org.junit.jupiter.api.condition.OS;
1515
import org.openqa.selenium.By;
16+
import org.openqa.selenium.OutputType;
1617
import org.openqa.selenium.WebElement;
1718
import org.openqa.selenium.firefox.FirefoxDriver;
1819
import org.openqa.selenium.firefox.FirefoxDriverLogLevel;
1920
import org.openqa.selenium.firefox.FirefoxDriverService;
2021
import org.openqa.selenium.firefox.FirefoxOptions;
2122
import org.openqa.selenium.firefox.GeckoDriverService;
2223
import org.openqa.selenium.remote.service.DriverFinder;
23-
import org.junit.jupiter.api.Disabled;
2424

2525
public class FirefoxTest extends BaseTest {
2626
private FirefoxDriver driver;
@@ -171,4 +171,22 @@ private Path getFirefoxLocation() {
171171
DriverFinder finder = new DriverFinder(GeckoDriverService.createDefaultService(), options);
172172
return Path.of(finder.getBrowserPath());
173173
}
174+
175+
@Test
176+
public void fullPageScreenshot() throws Exception {
177+
driver = startFirefoxDriver();
178+
179+
driver.get("https://www.selenium.dev");
180+
181+
File screenshot = driver.getFullPageScreenshotAs(OutputType.FILE);
182+
183+
File targetFile = new File("full_page_screenshot.png");
184+
Files.move(screenshot.toPath(), targetFile.toPath());
185+
186+
// Verify the screenshot file exists
187+
Assertions.assertTrue(targetFile.exists(), "The full page screenshot file should exist");
188+
Files.deleteIfExists(targetFile.toPath());
189+
190+
driver.quit();
191+
}
174192
}

website_and_docs/content/documentation/webdriver/browsers/firefox.en.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ please refer to the
414414

415415
{{< tabpane text=true >}}
416416
{{< tab header="Java" >}}
417-
{{< badge-code >}}
417+
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/browsers/FirefoxTest.java#L181" >}}
418418
{{< /tab >}}
419419
{{< tab header="Python" >}}
420420
{{< gh-codeblock path="/examples/python/tests/browsers/test_firefox.py#L139" >}}

website_and_docs/content/documentation/webdriver/browsers/firefox.ja.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ IDはアドオンインストール時の戻り値から取得できます。
412412

413413
{{< tabpane text=true >}}
414414
{{< tab header="Java" >}}
415-
{{< badge-code >}}
415+
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/browsers/FirefoxTest.java#L181" >}}
416416
{{< /tab >}}
417417
{{< tab header="Python" >}}
418418
{{< gh-codeblock path="/examples/python/tests/browsers/test_firefox.py#L139" >}}

website_and_docs/content/documentation/webdriver/browsers/firefox.pt-br.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ please refer to the
419419

420420
{{< tabpane text=true >}}
421421
{{< tab header="Java" >}}
422-
{{< badge-code >}}
422+
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/browsers/FirefoxTest.java#L181" >}}
423423
{{< /tab >}}
424424
{{< tab header="Python" >}}
425425
{{< gh-codeblock path="/examples/python/tests/browsers/test_firefox.py#L139" >}}

website_and_docs/content/documentation/webdriver/browsers/firefox.zh-cn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ please refer to the
416416

417417
{{< tabpane text=true >}}
418418
{{< tab header="Java" >}}
419-
{{< badge-code >}}
419+
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/browsers/FirefoxTest.java#L181" >}}
420420
{{< /tab >}}
421421
{{< tab header="Python" >}}
422422
{{< gh-codeblock path="/examples/python/tests/browsers/test_firefox.py#L139" >}}

0 commit comments

Comments
 (0)