org.openqa.selenium.devtools.v119.css.CSS Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of selenium-devtools-v119 Show documentation
Show all versions of selenium-devtools-v119 Show documentation
Selenium automates browsers. That's it! What you do with that power is entirely up to you.
package org.openqa.selenium.devtools.v119.css;
import org.openqa.selenium.Beta;
import org.openqa.selenium.devtools.Command;
import org.openqa.selenium.devtools.Event;
import org.openqa.selenium.devtools.ConverterFunctions;
import java.util.Map;
import java.util.LinkedHashMap;
import org.openqa.selenium.json.JsonInput;
/**
* This domain exposes CSS read/write operations. All CSS objects (stylesheets, rules, and styles)
* have an associated `id` used in subsequent operations on the related object. Each object type has
* a specific `id` structure, and those are not interchangeable between objects of different kinds.
* CSS objects can be loaded using the `get*ForNode()` calls (which accept a DOM node id). A client
* can also keep track of stylesheets via the `styleSheetAdded`/`styleSheetRemoved` events and
* subsequently load the required stylesheet contents using the `getStyleSheet[Text]()` methods.
*/
@Beta()
public class CSS {
/**
* Inserts a new rule with the given `ruleText` in a stylesheet with given `styleSheetId`, at the
* position specified by `location`.
*/
public static Command addRule(org.openqa.selenium.devtools.v119.css.model.StyleSheetId styleSheetId, java.lang.String ruleText, org.openqa.selenium.devtools.v119.css.model.SourceRange location) {
java.util.Objects.requireNonNull(styleSheetId, "styleSheetId is required");
java.util.Objects.requireNonNull(ruleText, "ruleText is required");
java.util.Objects.requireNonNull(location, "location is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("styleSheetId", styleSheetId);
params.put("ruleText", ruleText);
params.put("location", location);
return new Command<>("CSS.addRule", Map.copyOf(params), ConverterFunctions.map("rule", org.openqa.selenium.devtools.v119.css.model.CSSRule.class));
}
/**
* Returns all class names from specified stylesheet.
*/
public static Command> collectClassNames(org.openqa.selenium.devtools.v119.css.model.StyleSheetId styleSheetId) {
java.util.Objects.requireNonNull(styleSheetId, "styleSheetId is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("styleSheetId", styleSheetId);
return new Command<>("CSS.collectClassNames", Map.copyOf(params), ConverterFunctions.map("classNames", input -> input.readArray(java.lang.String.class)));
}
/**
* Creates a new special "via-inspector" stylesheet in the frame with given `frameId`.
*/
public static Command createStyleSheet(org.openqa.selenium.devtools.v119.page.model.FrameId frameId) {
java.util.Objects.requireNonNull(frameId, "frameId is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("frameId", frameId);
return new Command<>("CSS.createStyleSheet", Map.copyOf(params), ConverterFunctions.map("styleSheetId", org.openqa.selenium.devtools.v119.css.model.StyleSheetId.class));
}
/**
* Disables the CSS agent for the given page.
*/
public static Command disable() {
LinkedHashMap params = new LinkedHashMap<>();
return new Command<>("CSS.disable", Map.copyOf(params));
}
/**
* Enables the CSS agent for the given page. Clients should not assume that the CSS agent has been
* enabled until the result of this command is received.
*/
public static Command enable() {
LinkedHashMap params = new LinkedHashMap<>();
return new Command<>("CSS.enable", Map.copyOf(params));
}
/**
* Ensures that the given node will have specified pseudo-classes whenever its style is computed by
* the browser.
*/
public static Command forcePseudoState(org.openqa.selenium.devtools.v119.dom.model.NodeId nodeId, java.util.List forcedPseudoClasses) {
java.util.Objects.requireNonNull(nodeId, "nodeId is required");
java.util.Objects.requireNonNull(forcedPseudoClasses, "forcedPseudoClasses is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("nodeId", nodeId);
params.put("forcedPseudoClasses", forcedPseudoClasses);
return new Command<>("CSS.forcePseudoState", Map.copyOf(params));
}
public static class GetBackgroundColorsResponse {
private final java.util.Optional> backgroundColors;
private final java.util.Optional computedFontSize;
private final java.util.Optional computedFontWeight;
public GetBackgroundColorsResponse(java.util.Optional> backgroundColors, java.util.Optional computedFontSize, java.util.Optional computedFontWeight) {
this.backgroundColors = backgroundColors;
this.computedFontSize = computedFontSize;
this.computedFontWeight = computedFontWeight;
}
/**
* The range of background colors behind this element, if it contains any visible text. If no
* visible text is present, this will be undefined. In the case of a flat background color,
* this will consist of simply that color. In the case of a gradient, this will consist of each
* of the color stops. For anything more complicated, this will be an empty array. Images will
* be ignored (as if the image had failed to load).
*/
public java.util.Optional> getBackgroundColors() {
return backgroundColors;
}
/**
* The computed font size for this node, as a CSS computed value string (e.g. '12px').
*/
public java.util.Optional getComputedFontSize() {
return computedFontSize;
}
/**
* The computed font weight for this node, as a CSS computed value string (e.g. 'normal' or
* '100').
*/
public java.util.Optional getComputedFontWeight() {
return computedFontWeight;
}
private static GetBackgroundColorsResponse fromJson(JsonInput input) {
java.util.Optional> backgroundColors = java.util.Optional.empty();
java.util.Optional computedFontSize = java.util.Optional.empty();
java.util.Optional computedFontWeight = java.util.Optional.empty();
input.beginObject();
while (input.hasNext()) {
switch(input.nextName()) {
case "backgroundColors":
backgroundColors = java.util.Optional.ofNullable(input.readArray(java.lang.String.class));
break;
case "computedFontSize":
computedFontSize = java.util.Optional.ofNullable(input.nextString());
break;
case "computedFontWeight":
computedFontWeight = java.util.Optional.ofNullable(input.nextString());
break;
default:
input.skipValue();
break;
}
}
input.endObject();
return new GetBackgroundColorsResponse(backgroundColors, computedFontSize, computedFontWeight);
}
}
public static Command getBackgroundColors(org.openqa.selenium.devtools.v119.dom.model.NodeId nodeId) {
java.util.Objects.requireNonNull(nodeId, "nodeId is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("nodeId", nodeId);
return new Command<>("CSS.getBackgroundColors", Map.copyOf(params), input -> input.read(org.openqa.selenium.devtools.v119.css.CSS.GetBackgroundColorsResponse.class));
}
/**
* Returns the computed style for a DOM node identified by `nodeId`.
*/
public static Command> getComputedStyleForNode(org.openqa.selenium.devtools.v119.dom.model.NodeId nodeId) {
java.util.Objects.requireNonNull(nodeId, "nodeId is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("nodeId", nodeId);
return new Command<>("CSS.getComputedStyleForNode", Map.copyOf(params), ConverterFunctions.map("computedStyle", input -> input.readArray(org.openqa.selenium.devtools.v119.css.model.CSSComputedStyleProperty.class)));
}
public static class GetInlineStylesForNodeResponse {
private final java.util.Optional inlineStyle;
private final java.util.Optional attributesStyle;
public GetInlineStylesForNodeResponse(java.util.Optional inlineStyle, java.util.Optional attributesStyle) {
this.inlineStyle = inlineStyle;
this.attributesStyle = attributesStyle;
}
/**
* Inline style for the specified DOM node.
*/
public java.util.Optional getInlineStyle() {
return inlineStyle;
}
/**
* Attribute-defined element style (e.g. resulting from "width=20 height=100%").
*/
public java.util.Optional getAttributesStyle() {
return attributesStyle;
}
private static GetInlineStylesForNodeResponse fromJson(JsonInput input) {
java.util.Optional inlineStyle = java.util.Optional.empty();
java.util.Optional attributesStyle = java.util.Optional.empty();
input.beginObject();
while (input.hasNext()) {
switch(input.nextName()) {
case "inlineStyle":
inlineStyle = java.util.Optional.ofNullable(input.read(org.openqa.selenium.devtools.v119.css.model.CSSStyle.class));
break;
case "attributesStyle":
attributesStyle = java.util.Optional.ofNullable(input.read(org.openqa.selenium.devtools.v119.css.model.CSSStyle.class));
break;
default:
input.skipValue();
break;
}
}
input.endObject();
return new GetInlineStylesForNodeResponse(inlineStyle, attributesStyle);
}
}
/**
* Returns the styles defined inline (explicitly in the "style" attribute and implicitly, using DOM
* attributes) for a DOM node identified by `nodeId`.
*/
public static Command getInlineStylesForNode(org.openqa.selenium.devtools.v119.dom.model.NodeId nodeId) {
java.util.Objects.requireNonNull(nodeId, "nodeId is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("nodeId", nodeId);
return new Command<>("CSS.getInlineStylesForNode", Map.copyOf(params), input -> input.read(org.openqa.selenium.devtools.v119.css.CSS.GetInlineStylesForNodeResponse.class));
}
public static class GetMatchedStylesForNodeResponse {
private final java.util.Optional inlineStyle;
private final java.util.Optional attributesStyle;
private final java.util.Optional> matchedCSSRules;
private final java.util.Optional> pseudoElements;
private final java.util.Optional> inherited;
private final java.util.Optional> inheritedPseudoElements;
private final java.util.Optional> cssKeyframesRules;
private final java.util.Optional> cssPositionFallbackRules;
private final java.util.Optional> cssPropertyRules;
private final java.util.Optional> cssPropertyRegistrations;
private final java.util.Optional parentLayoutNodeId;
public GetMatchedStylesForNodeResponse(java.util.Optional inlineStyle, java.util.Optional attributesStyle, java.util.Optional> matchedCSSRules, java.util.Optional> pseudoElements, java.util.Optional> inherited, java.util.Optional> inheritedPseudoElements, java.util.Optional> cssKeyframesRules, java.util.Optional> cssPositionFallbackRules, java.util.Optional> cssPropertyRules, java.util.Optional> cssPropertyRegistrations, java.util.Optional parentLayoutNodeId) {
this.inlineStyle = inlineStyle;
this.attributesStyle = attributesStyle;
this.matchedCSSRules = matchedCSSRules;
this.pseudoElements = pseudoElements;
this.inherited = inherited;
this.inheritedPseudoElements = inheritedPseudoElements;
this.cssKeyframesRules = cssKeyframesRules;
this.cssPositionFallbackRules = cssPositionFallbackRules;
this.cssPropertyRules = cssPropertyRules;
this.cssPropertyRegistrations = cssPropertyRegistrations;
this.parentLayoutNodeId = parentLayoutNodeId;
}
/**
* Inline style for the specified DOM node.
*/
public java.util.Optional getInlineStyle() {
return inlineStyle;
}
/**
* Attribute-defined element style (e.g. resulting from "width=20 height=100%").
*/
public java.util.Optional getAttributesStyle() {
return attributesStyle;
}
/**
* CSS rules matching this node, from all applicable stylesheets.
*/
public java.util.Optional> getMatchedCSSRules() {
return matchedCSSRules;
}
/**
* Pseudo style matches for this node.
*/
public java.util.Optional> getPseudoElements() {
return pseudoElements;
}
/**
* A chain of inherited styles (from the immediate node parent up to the DOM tree root).
*/
public java.util.Optional> getInherited() {
return inherited;
}
/**
* A chain of inherited pseudo element styles (from the immediate node parent up to the DOM tree root).
*/
public java.util.Optional> getInheritedPseudoElements() {
return inheritedPseudoElements;
}
/**
* A list of CSS keyframed animations matching this node.
*/
public java.util.Optional> getCssKeyframesRules() {
return cssKeyframesRules;
}
/**
* A list of CSS position fallbacks matching this node.
*/
public java.util.Optional> getCssPositionFallbackRules() {
return cssPositionFallbackRules;
}
/**
* A list of CSS at-property rules matching this node.
*/
public java.util.Optional> getCssPropertyRules() {
return cssPropertyRules;
}
/**
* A list of CSS property registrations matching this node.
*/
public java.util.Optional> getCssPropertyRegistrations() {
return cssPropertyRegistrations;
}
/**
* Id of the first parent element that does not have display: contents.
*/
public java.util.Optional getParentLayoutNodeId() {
return parentLayoutNodeId;
}
private static GetMatchedStylesForNodeResponse fromJson(JsonInput input) {
java.util.Optional inlineStyle = java.util.Optional.empty();
java.util.Optional attributesStyle = java.util.Optional.empty();
java.util.Optional> matchedCSSRules = java.util.Optional.empty();
java.util.Optional> pseudoElements = java.util.Optional.empty();
java.util.Optional> inherited = java.util.Optional.empty();
java.util.Optional> inheritedPseudoElements = java.util.Optional.empty();
java.util.Optional> cssKeyframesRules = java.util.Optional.empty();
java.util.Optional> cssPositionFallbackRules = java.util.Optional.empty();
java.util.Optional> cssPropertyRules = java.util.Optional.empty();
java.util.Optional> cssPropertyRegistrations = java.util.Optional.empty();
java.util.Optional parentLayoutNodeId = java.util.Optional.empty();
input.beginObject();
while (input.hasNext()) {
switch(input.nextName()) {
case "inlineStyle":
inlineStyle = java.util.Optional.ofNullable(input.read(org.openqa.selenium.devtools.v119.css.model.CSSStyle.class));
break;
case "attributesStyle":
attributesStyle = java.util.Optional.ofNullable(input.read(org.openqa.selenium.devtools.v119.css.model.CSSStyle.class));
break;
case "matchedCSSRules":
matchedCSSRules = java.util.Optional.ofNullable(input.readArray(org.openqa.selenium.devtools.v119.css.model.RuleMatch.class));
break;
case "pseudoElements":
pseudoElements = java.util.Optional.ofNullable(input.readArray(org.openqa.selenium.devtools.v119.css.model.PseudoElementMatches.class));
break;
case "inherited":
inherited = java.util.Optional.ofNullable(input.readArray(org.openqa.selenium.devtools.v119.css.model.InheritedStyleEntry.class));
break;
case "inheritedPseudoElements":
inheritedPseudoElements = java.util.Optional.ofNullable(input.readArray(org.openqa.selenium.devtools.v119.css.model.InheritedPseudoElementMatches.class));
break;
case "cssKeyframesRules":
cssKeyframesRules = java.util.Optional.ofNullable(input.readArray(org.openqa.selenium.devtools.v119.css.model.CSSKeyframesRule.class));
break;
case "cssPositionFallbackRules":
cssPositionFallbackRules = java.util.Optional.ofNullable(input.readArray(org.openqa.selenium.devtools.v119.css.model.CSSPositionFallbackRule.class));
break;
case "cssPropertyRules":
cssPropertyRules = java.util.Optional.ofNullable(input.readArray(org.openqa.selenium.devtools.v119.css.model.CSSPropertyRule.class));
break;
case "cssPropertyRegistrations":
cssPropertyRegistrations = java.util.Optional.ofNullable(input.readArray(org.openqa.selenium.devtools.v119.css.model.CSSPropertyRegistration.class));
break;
case "parentLayoutNodeId":
parentLayoutNodeId = java.util.Optional.ofNullable(input.read(org.openqa.selenium.devtools.v119.dom.model.NodeId.class));
break;
default:
input.skipValue();
break;
}
}
input.endObject();
return new GetMatchedStylesForNodeResponse(inlineStyle, attributesStyle, matchedCSSRules, pseudoElements, inherited, inheritedPseudoElements, cssKeyframesRules, cssPositionFallbackRules, cssPropertyRules, cssPropertyRegistrations, parentLayoutNodeId);
}
}
/**
* Returns requested styles for a DOM node identified by `nodeId`.
*/
public static Command getMatchedStylesForNode(org.openqa.selenium.devtools.v119.dom.model.NodeId nodeId) {
java.util.Objects.requireNonNull(nodeId, "nodeId is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("nodeId", nodeId);
return new Command<>("CSS.getMatchedStylesForNode", Map.copyOf(params), input -> input.read(org.openqa.selenium.devtools.v119.css.CSS.GetMatchedStylesForNodeResponse.class));
}
/**
* Returns all media queries parsed by the rendering engine.
*/
public static Command> getMediaQueries() {
LinkedHashMap params = new LinkedHashMap<>();
return new Command<>("CSS.getMediaQueries", Map.copyOf(params), ConverterFunctions.map("medias", input -> input.readArray(org.openqa.selenium.devtools.v119.css.model.CSSMedia.class)));
}
/**
* Requests information about platform fonts which we used to render child TextNodes in the given
* node.
*/
public static Command> getPlatformFontsForNode(org.openqa.selenium.devtools.v119.dom.model.NodeId nodeId) {
java.util.Objects.requireNonNull(nodeId, "nodeId is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("nodeId", nodeId);
return new Command<>("CSS.getPlatformFontsForNode", Map.copyOf(params), ConverterFunctions.map("fonts", input -> input.readArray(org.openqa.selenium.devtools.v119.css.model.PlatformFontUsage.class)));
}
/**
* Returns the current textual content for a stylesheet.
*/
public static Command getStyleSheetText(org.openqa.selenium.devtools.v119.css.model.StyleSheetId styleSheetId) {
java.util.Objects.requireNonNull(styleSheetId, "styleSheetId is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("styleSheetId", styleSheetId);
return new Command<>("CSS.getStyleSheetText", Map.copyOf(params), ConverterFunctions.map("text", java.lang.String.class));
}
/**
* Returns all layers parsed by the rendering engine for the tree scope of a node.
* Given a DOM element identified by nodeId, getLayersForNode returns the root
* layer for the nearest ancestor document or shadow root. The layer root contains
* the full layer tree for the tree scope and their ordering.
*/
@Beta()
public static Command getLayersForNode(org.openqa.selenium.devtools.v119.dom.model.NodeId nodeId) {
java.util.Objects.requireNonNull(nodeId, "nodeId is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("nodeId", nodeId);
return new Command<>("CSS.getLayersForNode", Map.copyOf(params), ConverterFunctions.map("rootLayer", org.openqa.selenium.devtools.v119.css.model.CSSLayerData.class));
}
/**
* Starts tracking the given computed styles for updates. The specified array of properties
* replaces the one previously specified. Pass empty array to disable tracking.
* Use takeComputedStyleUpdates to retrieve the list of nodes that had properties modified.
* The changes to computed style properties are only tracked for nodes pushed to the front-end
* by the DOM agent. If no changes to the tracked properties occur after the node has been pushed
* to the front-end, no updates will be issued for the node.
*/
@Beta()
public static Command trackComputedStyleUpdates(java.util.List propertiesToTrack) {
java.util.Objects.requireNonNull(propertiesToTrack, "propertiesToTrack is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("propertiesToTrack", propertiesToTrack);
return new Command<>("CSS.trackComputedStyleUpdates", Map.copyOf(params));
}
/**
* Polls the next batch of computed style updates.
*/
@Beta()
public static Command> takeComputedStyleUpdates() {
LinkedHashMap params = new LinkedHashMap<>();
return new Command<>("CSS.takeComputedStyleUpdates", Map.copyOf(params), ConverterFunctions.map("nodeIds", input -> input.readArray(org.openqa.selenium.devtools.v119.dom.model.NodeId.class)));
}
/**
* Find a rule with the given active property for the given node and set the new value for this
* property
*/
public static Command setEffectivePropertyValueForNode(org.openqa.selenium.devtools.v119.dom.model.NodeId nodeId, java.lang.String propertyName, java.lang.String value) {
java.util.Objects.requireNonNull(nodeId, "nodeId is required");
java.util.Objects.requireNonNull(propertyName, "propertyName is required");
java.util.Objects.requireNonNull(value, "value is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("nodeId", nodeId);
params.put("propertyName", propertyName);
params.put("value", value);
return new Command<>("CSS.setEffectivePropertyValueForNode", Map.copyOf(params));
}
/**
* Modifies the property rule property name.
*/
public static Command setPropertyRulePropertyName(org.openqa.selenium.devtools.v119.css.model.StyleSheetId styleSheetId, org.openqa.selenium.devtools.v119.css.model.SourceRange range, java.lang.String propertyName) {
java.util.Objects.requireNonNull(styleSheetId, "styleSheetId is required");
java.util.Objects.requireNonNull(range, "range is required");
java.util.Objects.requireNonNull(propertyName, "propertyName is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("styleSheetId", styleSheetId);
params.put("range", range);
params.put("propertyName", propertyName);
return new Command<>("CSS.setPropertyRulePropertyName", Map.copyOf(params), ConverterFunctions.map("propertyName", org.openqa.selenium.devtools.v119.css.model.Value.class));
}
/**
* Modifies the keyframe rule key text.
*/
public static Command setKeyframeKey(org.openqa.selenium.devtools.v119.css.model.StyleSheetId styleSheetId, org.openqa.selenium.devtools.v119.css.model.SourceRange range, java.lang.String keyText) {
java.util.Objects.requireNonNull(styleSheetId, "styleSheetId is required");
java.util.Objects.requireNonNull(range, "range is required");
java.util.Objects.requireNonNull(keyText, "keyText is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("styleSheetId", styleSheetId);
params.put("range", range);
params.put("keyText", keyText);
return new Command<>("CSS.setKeyframeKey", Map.copyOf(params), ConverterFunctions.map("keyText", org.openqa.selenium.devtools.v119.css.model.Value.class));
}
/**
* Modifies the rule selector.
*/
public static Command setMediaText(org.openqa.selenium.devtools.v119.css.model.StyleSheetId styleSheetId, org.openqa.selenium.devtools.v119.css.model.SourceRange range, java.lang.String text) {
java.util.Objects.requireNonNull(styleSheetId, "styleSheetId is required");
java.util.Objects.requireNonNull(range, "range is required");
java.util.Objects.requireNonNull(text, "text is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("styleSheetId", styleSheetId);
params.put("range", range);
params.put("text", text);
return new Command<>("CSS.setMediaText", Map.copyOf(params), ConverterFunctions.map("media", org.openqa.selenium.devtools.v119.css.model.CSSMedia.class));
}
/**
* Modifies the expression of a container query.
*/
@Beta()
public static Command setContainerQueryText(org.openqa.selenium.devtools.v119.css.model.StyleSheetId styleSheetId, org.openqa.selenium.devtools.v119.css.model.SourceRange range, java.lang.String text) {
java.util.Objects.requireNonNull(styleSheetId, "styleSheetId is required");
java.util.Objects.requireNonNull(range, "range is required");
java.util.Objects.requireNonNull(text, "text is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("styleSheetId", styleSheetId);
params.put("range", range);
params.put("text", text);
return new Command<>("CSS.setContainerQueryText", Map.copyOf(params), ConverterFunctions.map("containerQuery", org.openqa.selenium.devtools.v119.css.model.CSSContainerQuery.class));
}
/**
* Modifies the expression of a supports at-rule.
*/
@Beta()
public static Command setSupportsText(org.openqa.selenium.devtools.v119.css.model.StyleSheetId styleSheetId, org.openqa.selenium.devtools.v119.css.model.SourceRange range, java.lang.String text) {
java.util.Objects.requireNonNull(styleSheetId, "styleSheetId is required");
java.util.Objects.requireNonNull(range, "range is required");
java.util.Objects.requireNonNull(text, "text is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("styleSheetId", styleSheetId);
params.put("range", range);
params.put("text", text);
return new Command<>("CSS.setSupportsText", Map.copyOf(params), ConverterFunctions.map("supports", org.openqa.selenium.devtools.v119.css.model.CSSSupports.class));
}
/**
* Modifies the expression of a scope at-rule.
*/
@Beta()
public static Command setScopeText(org.openqa.selenium.devtools.v119.css.model.StyleSheetId styleSheetId, org.openqa.selenium.devtools.v119.css.model.SourceRange range, java.lang.String text) {
java.util.Objects.requireNonNull(styleSheetId, "styleSheetId is required");
java.util.Objects.requireNonNull(range, "range is required");
java.util.Objects.requireNonNull(text, "text is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("styleSheetId", styleSheetId);
params.put("range", range);
params.put("text", text);
return new Command<>("CSS.setScopeText", Map.copyOf(params), ConverterFunctions.map("scope", org.openqa.selenium.devtools.v119.css.model.CSSScope.class));
}
/**
* Modifies the rule selector.
*/
public static Command setRuleSelector(org.openqa.selenium.devtools.v119.css.model.StyleSheetId styleSheetId, org.openqa.selenium.devtools.v119.css.model.SourceRange range, java.lang.String selector) {
java.util.Objects.requireNonNull(styleSheetId, "styleSheetId is required");
java.util.Objects.requireNonNull(range, "range is required");
java.util.Objects.requireNonNull(selector, "selector is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("styleSheetId", styleSheetId);
params.put("range", range);
params.put("selector", selector);
return new Command<>("CSS.setRuleSelector", Map.copyOf(params), ConverterFunctions.map("selectorList", org.openqa.selenium.devtools.v119.css.model.SelectorList.class));
}
/**
* Sets the new stylesheet text.
*/
public static Command setStyleSheetText(org.openqa.selenium.devtools.v119.css.model.StyleSheetId styleSheetId, java.lang.String text) {
java.util.Objects.requireNonNull(styleSheetId, "styleSheetId is required");
java.util.Objects.requireNonNull(text, "text is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("styleSheetId", styleSheetId);
params.put("text", text);
return new Command<>("CSS.setStyleSheetText", Map.copyOf(params), ConverterFunctions.map("sourceMapURL", java.lang.String.class));
}
/**
* Applies specified style edits one after another in the given order.
*/
public static Command> setStyleTexts(java.util.List edits) {
java.util.Objects.requireNonNull(edits, "edits is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("edits", edits);
return new Command<>("CSS.setStyleTexts", Map.copyOf(params), ConverterFunctions.map("styles", input -> input.readArray(org.openqa.selenium.devtools.v119.css.model.CSSStyle.class)));
}
/**
* Enables the selector recording.
*/
public static Command startRuleUsageTracking() {
LinkedHashMap params = new LinkedHashMap<>();
return new Command<>("CSS.startRuleUsageTracking", Map.copyOf(params));
}
/**
* Stop tracking rule usage and return the list of rules that were used since last call to
* `takeCoverageDelta` (or since start of coverage instrumentation).
*/
public static Command> stopRuleUsageTracking() {
LinkedHashMap params = new LinkedHashMap<>();
return new Command<>("CSS.stopRuleUsageTracking", Map.copyOf(params), ConverterFunctions.map("ruleUsage", input -> input.readArray(org.openqa.selenium.devtools.v119.css.model.RuleUsage.class)));
}
public static class TakeCoverageDeltaResponse {
private final java.util.List coverage;
private final java.lang.Number timestamp;
public TakeCoverageDeltaResponse(java.util.List coverage, java.lang.Number timestamp) {
this.coverage = java.util.Objects.requireNonNull(coverage, "coverage is required");
this.timestamp = java.util.Objects.requireNonNull(timestamp, "timestamp is required");
}
public java.util.List getCoverage() {
return coverage;
}
/**
* Monotonically increasing time, in seconds.
*/
public java.lang.Number getTimestamp() {
return timestamp;
}
private static TakeCoverageDeltaResponse fromJson(JsonInput input) {
java.util.List coverage = null;
java.lang.Number timestamp = 0;
input.beginObject();
while (input.hasNext()) {
switch(input.nextName()) {
case "coverage":
coverage = input.readArray(org.openqa.selenium.devtools.v119.css.model.RuleUsage.class);
break;
case "timestamp":
timestamp = input.nextNumber();
break;
default:
input.skipValue();
break;
}
}
input.endObject();
return new TakeCoverageDeltaResponse(coverage, timestamp);
}
}
/**
* Obtain list of rules that became used since last call to this method (or since start of coverage
* instrumentation).
*/
public static Command takeCoverageDelta() {
LinkedHashMap params = new LinkedHashMap<>();
return new Command<>("CSS.takeCoverageDelta", Map.copyOf(params), input -> input.read(org.openqa.selenium.devtools.v119.css.CSS.TakeCoverageDeltaResponse.class));
}
/**
* Enables/disables rendering of local CSS fonts (enabled by default).
*/
@Beta()
public static Command setLocalFontsEnabled(java.lang.Boolean enabled) {
java.util.Objects.requireNonNull(enabled, "enabled is required");
LinkedHashMap params = new LinkedHashMap<>();
params.put("enabled", enabled);
return new Command<>("CSS.setLocalFontsEnabled", Map.copyOf(params));
}
public static Event fontsUpdated() {
return new Event<>("CSS.fontsUpdated", ConverterFunctions.map("font", org.openqa.selenium.devtools.v119.css.model.FontFace.class));
}
public static Event mediaQueryResultChanged() {
return new Event<>("CSS.mediaQueryResultChanged", ConverterFunctions.empty());
}
public static Event styleSheetAdded() {
return new Event<>("CSS.styleSheetAdded", ConverterFunctions.map("header", org.openqa.selenium.devtools.v119.css.model.CSSStyleSheetHeader.class));
}
public static Event styleSheetChanged() {
return new Event<>("CSS.styleSheetChanged", ConverterFunctions.map("styleSheetId", org.openqa.selenium.devtools.v119.css.model.StyleSheetId.class));
}
public static Event styleSheetRemoved() {
return new Event<>("CSS.styleSheetRemoved", ConverterFunctions.map("styleSheetId", org.openqa.selenium.devtools.v119.css.model.StyleSheetId.class));
}
}