Class ElementHandle.ScreenshotOptions

java.lang.Object
com.microsoft.playwright.ElementHandle.ScreenshotOptions
Enclosing interface:
ElementHandle

public static class ElementHandle.ScreenshotOptions extends Object
  • Field Details

    • animations

      public ScreenshotAnimations animations
      When set to "disabled", stops CSS animations, CSS transitions and Web Animations. Animations get different treatment depending on their duration:
      • finite animations are fast-forwarded to completion, so they'll fire transitionend event.
      • infinite animations are canceled to initial state, and then played over after the screenshot.

      Defaults to "allow" that leaves animations untouched.

    • caret

      public ScreenshotCaret caret
      When set to "hide", screenshot will hide text caret. When set to "initial", text caret behavior will not be changed. Defaults to "hide".
    • mask

      public List<Locator> mask
      Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box #FF00FF (customized by maskColor) that completely covers its bounding box.
    • maskColor

      public String maskColor
      Specify the color of the overlay box for masked elements, in CSS color format. Default color is pink #FF00FF.
    • omitBackground

      public Boolean omitBackground
      Hides default white background and allows capturing screenshots with transparency. Not applicable to jpeg images. Defaults to false.
    • path

      public Path path
      The file path to save the image to. The screenshot type will be inferred from file extension. If path is a relative path, then it is resolved relative to the current working directory. If no path is provided, the image won't be saved to the disk.
    • quality

      public Integer quality
      The quality of the image, between 0-100. Not applicable to png images.
    • scale

      public ScreenshotScale scale
      When set to "css", screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will keep screenshots small. Using "device" option will produce a single pixel per each device pixel, so screenshots of high-dpi devices will be twice as large or even larger.

      Defaults to "device".

    • timeout

      public Double timeout
      Maximum time in milliseconds. Defaults to 30000 (30 seconds). Pass 0 to disable timeout. The default value can be changed by using the BrowserContext.setDefaultTimeout() or Page.setDefaultTimeout() methods.
    • type

      public ScreenshotType type
      Specify screenshot type, defaults to png.
  • Constructor Details

    • ScreenshotOptions

      public ScreenshotOptions()
  • Method Details

    • setAnimations

      public ElementHandle.ScreenshotOptions setAnimations(ScreenshotAnimations animations)
      When set to "disabled", stops CSS animations, CSS transitions and Web Animations. Animations get different treatment depending on their duration:
      • finite animations are fast-forwarded to completion, so they'll fire transitionend event.
      • infinite animations are canceled to initial state, and then played over after the screenshot.

      Defaults to "allow" that leaves animations untouched.

    • setCaret

      When set to "hide", screenshot will hide text caret. When set to "initial", text caret behavior will not be changed. Defaults to "hide".
    • setMask

      Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box #FF00FF (customized by maskColor) that completely covers its bounding box.
    • setMaskColor

      public ElementHandle.ScreenshotOptions setMaskColor(String maskColor)
      Specify the color of the overlay box for masked elements, in CSS color format. Default color is pink #FF00FF.
    • setOmitBackground

      public ElementHandle.ScreenshotOptions setOmitBackground(boolean omitBackground)
      Hides default white background and allows capturing screenshots with transparency. Not applicable to jpeg images. Defaults to false.
    • setPath

      public ElementHandle.ScreenshotOptions setPath(Path path)
      The file path to save the image to. The screenshot type will be inferred from file extension. If path is a relative path, then it is resolved relative to the current working directory. If no path is provided, the image won't be saved to the disk.
    • setQuality

      public ElementHandle.ScreenshotOptions setQuality(int quality)
      The quality of the image, between 0-100. Not applicable to png images.
    • setScale

      When set to "css", screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will keep screenshots small. Using "device" option will produce a single pixel per each device pixel, so screenshots of high-dpi devices will be twice as large or even larger.

      Defaults to "device".

    • setTimeout

      public ElementHandle.ScreenshotOptions setTimeout(double timeout)
      Maximum time in milliseconds. Defaults to 30000 (30 seconds). Pass 0 to disable timeout. The default value can be changed by using the BrowserContext.setDefaultTimeout() or Page.setDefaultTimeout() methods.
    • setType

      Specify screenshot type, defaults to png.