Package com.microsoft.playwright
Class Locator.ScreenshotOptions
- java.lang.Object
-
- com.microsoft.playwright.Locator.ScreenshotOptions
-
-
Field Summary
Fields Modifier and Type Field Description ScreenshotAnimationsanimationsWhen set to"disabled", stops CSS animations, CSS transitions and Web Animations.ScreenshotCaretcaretWhen set to"hide", screenshot will hide text caret.List<Locator>maskSpecify locators that should be masked when the screenshot is taken.StringmaskColorSpecify the color of the overlay box for masked elements, in CSS color format.BooleanomitBackgroundHides default white background and allows capturing screenshots with transparency.PathpathThe file path to save the image to.IntegerqualityThe quality of the image, between 0-100.ScreenshotScalescaleWhen set to"css", screenshot will have a single pixel per each css pixel on the page.StringstyleText of the stylesheet to apply while making the screenshot.DoubletimeoutMaximum time in milliseconds.ScreenshotTypetypeSpecify screenshot type, defaults topng.
-
Constructor Summary
Constructors Constructor Description ScreenshotOptions()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Locator.ScreenshotOptionssetAnimations(ScreenshotAnimations animations)When set to"disabled", stops CSS animations, CSS transitions and Web Animations.Locator.ScreenshotOptionssetCaret(ScreenshotCaret caret)When set to"hide", screenshot will hide text caret.Locator.ScreenshotOptionssetMask(List<Locator> mask)Specify locators that should be masked when the screenshot is taken.Locator.ScreenshotOptionssetMaskColor(String maskColor)Specify the color of the overlay box for masked elements, in CSS color format.Locator.ScreenshotOptionssetOmitBackground(boolean omitBackground)Hides default white background and allows capturing screenshots with transparency.Locator.ScreenshotOptionssetPath(Path path)The file path to save the image to.Locator.ScreenshotOptionssetQuality(int quality)The quality of the image, between 0-100.Locator.ScreenshotOptionssetScale(ScreenshotScale scale)When set to"css", screenshot will have a single pixel per each css pixel on the page.Locator.ScreenshotOptionssetStyle(String style)Text of the stylesheet to apply while making the screenshot.Locator.ScreenshotOptionssetTimeout(double timeout)Maximum time in milliseconds.Locator.ScreenshotOptionssetType(ScreenshotType type)Specify screenshot type, defaults topng.
-
-
-
Field Detail
-
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
transitionendevent. - infinite animations are canceled to initial state, and then played over after the screenshot.
Defaults to
"allow"that leaves animations untouched. - finite animations are fast-forwarded to completion, so they'll fire
-
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 bymaskColor) 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 tojpegimages. Defaults tofalse.
-
path
public Path path
The file path to save the image to. The screenshot type will be inferred from file extension. Ifpathis 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 topngimages.
-
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".
-
style
public String style
Text of the stylesheet to apply while making the screenshot. This is where you can hide dynamic elements, make elements invisible or change their properties to help you creating repeatable screenshots. This stylesheet pierces the Shadow DOM and applies to the inner frames.
-
timeout
public Double timeout
Maximum time in milliseconds. Defaults to30000(30 seconds). Pass0to disable timeout. The default value can be changed by using theBrowserContext.setDefaultTimeout()orPage.setDefaultTimeout()methods.
-
type
public ScreenshotType type
Specify screenshot type, defaults topng.
-
-
Method Detail
-
setAnimations
public Locator.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
transitionendevent. - infinite animations are canceled to initial state, and then played over after the screenshot.
Defaults to
"allow"that leaves animations untouched. - finite animations are fast-forwarded to completion, so they'll fire
-
setCaret
public Locator.ScreenshotOptions setCaret(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".
-
setMask
public Locator.ScreenshotOptions setMask(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 bymaskColor) that completely covers its bounding box.
-
setMaskColor
public Locator.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 Locator.ScreenshotOptions setOmitBackground(boolean omitBackground)
Hides default white background and allows capturing screenshots with transparency. Not applicable tojpegimages. Defaults tofalse.
-
setPath
public Locator.ScreenshotOptions setPath(Path path)
The file path to save the image to. The screenshot type will be inferred from file extension. Ifpathis 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 Locator.ScreenshotOptions setQuality(int quality)
The quality of the image, between 0-100. Not applicable topngimages.
-
setScale
public Locator.ScreenshotOptions setScale(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".
-
setStyle
public Locator.ScreenshotOptions setStyle(String style)
Text of the stylesheet to apply while making the screenshot. This is where you can hide dynamic elements, make elements invisible or change their properties to help you creating repeatable screenshots. This stylesheet pierces the Shadow DOM and applies to the inner frames.
-
setTimeout
public Locator.ScreenshotOptions setTimeout(double timeout)
Maximum time in milliseconds. Defaults to30000(30 seconds). Pass0to disable timeout. The default value can be changed by using theBrowserContext.setDefaultTimeout()orPage.setDefaultTimeout()methods.
-
setType
public Locator.ScreenshotOptions setType(ScreenshotType type)
Specify screenshot type, defaults topng.
-
-