Skip to content

Commit

Permalink
[java]: docs example for full page screenshot in firefox (#2066)
Browse files Browse the repository at this point in the history
* java docs for full page screenshot in firefox

* delete the file after assertion

---------

Co-authored-by: Sri Harsha <[email protected]>
  • Loading branch information
navin772 and harsha509 authored Nov 18, 2024
1 parent 9c3d182 commit 55a8ef0
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.OS;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxDriverLogLevel;
import org.openqa.selenium.firefox.FirefoxDriverService;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.firefox.GeckoDriverService;
import org.openqa.selenium.remote.service.DriverFinder;
import org.junit.jupiter.api.Disabled;

public class FirefoxTest extends BaseTest {
private FirefoxDriver driver;
Expand Down Expand Up @@ -171,4 +171,22 @@ private Path getFirefoxLocation() {
DriverFinder finder = new DriverFinder(GeckoDriverService.createDefaultService(), options);
return Path.of(finder.getBrowserPath());
}

@Test
public void fullPageScreenshot() throws Exception {
driver = startFirefoxDriver();

driver.get("https://www.selenium.dev");

File screenshot = driver.getFullPageScreenshotAs(OutputType.FILE);

File targetFile = new File("full_page_screenshot.png");
Files.move(screenshot.toPath(), targetFile.toPath());

// Verify the screenshot file exists
Assertions.assertTrue(targetFile.exists(), "The full page screenshot file should exist");
Files.deleteIfExists(targetFile.toPath());

driver.quit();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ please refer to the

{{< tabpane text=true >}}
{{< tab header="Java" >}}
{{< badge-code >}}
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/browsers/FirefoxTest.java#L181" >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< gh-codeblock path="/examples/python/tests/browsers/test_firefox.py#L139" >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ IDはアドオンインストール時の戻り値から取得できます。

{{< tabpane text=true >}}
{{< tab header="Java" >}}
{{< badge-code >}}
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/browsers/FirefoxTest.java#L181" >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< gh-codeblock path="/examples/python/tests/browsers/test_firefox.py#L139" >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ please refer to the

{{< tabpane text=true >}}
{{< tab header="Java" >}}
{{< badge-code >}}
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/browsers/FirefoxTest.java#L181" >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< gh-codeblock path="/examples/python/tests/browsers/test_firefox.py#L139" >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ please refer to the

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

0 comments on commit 55a8ef0

Please sign in to comment.