Class CSS
java.lang.Object
org.openqa.selenium.devtools.v133.css.CSS
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static class
static class
static class
static class
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.openqa.selenium.devtools.Command<CSSRule>
addRule
(StyleSheetId styleSheetId, String ruleText, SourceRange location, Optional<NodeId> nodeForPropertySyntaxValidation) Inserts a new rule with the given `ruleText` in a stylesheet with given `styleSheetId`, at the position specified by `location`.collectClassNames
(StyleSheetId styleSheetId) Returns all class names from specified stylesheet.static org.openqa.selenium.devtools.Event<NodeId>
static org.openqa.selenium.devtools.Command<StyleSheetId>
createStyleSheet
(FrameId frameId) Creates a new special "via-inspector" stylesheet in the frame with given `frameId`.static org.openqa.selenium.devtools.Command<Void>
disable()
Disables the CSS agent for the given page.static org.openqa.selenium.devtools.Command<Void>
enable()
Enables the CSS agent for the given page.static org.openqa.selenium.devtools.Event<FontFace>
static org.openqa.selenium.devtools.Command<Void>
forcePseudoState
(NodeId nodeId, List<String> forcedPseudoClasses) Ensures that the given node will have specified pseudo-classes whenever its style is computed by the browser.static org.openqa.selenium.devtools.Command<Void>
forceStartingStyle
(NodeId nodeId, Boolean forced) Ensures that the given node is in its starting-style state.static org.openqa.selenium.devtools.Command<CSS.GetAnimatedStylesForNodeResponse>
getAnimatedStylesForNode
(NodeId nodeId) Returns the styles coming from animations & transitions including the animation & transition styles coming from inheritance chain.static org.openqa.selenium.devtools.Command<CSS.GetBackgroundColorsResponse>
getBackgroundColors
(NodeId nodeId) static org.openqa.selenium.devtools.Command<List<CSSComputedStyleProperty>>
getComputedStyleForNode
(NodeId nodeId) Returns the computed style for a DOM node identified by `nodeId`.static org.openqa.selenium.devtools.Command<CSS.GetInlineStylesForNodeResponse>
getInlineStylesForNode
(NodeId nodeId) Returns the styles defined inline (explicitly in the "style" attribute and implicitly, using DOM attributes) for a DOM node identified by `nodeId`.static org.openqa.selenium.devtools.Command<CSSLayerData>
getLayersForNode
(NodeId nodeId) Returns all layers parsed by the rendering engine for the tree scope of a node.static org.openqa.selenium.devtools.Command<List<SourceRange>>
getLocationForSelector
(StyleSheetId styleSheetId, String selectorText) Given a CSS selector text and a style sheet ID, getLocationForSelector returns an array of locations of the CSS selector in the style sheet.static org.openqa.selenium.devtools.Command<List<CSSProperty>>
getLonghandProperties
(String shorthandName, String value) static org.openqa.selenium.devtools.Command<CSS.GetMatchedStylesForNodeResponse>
getMatchedStylesForNode
(NodeId nodeId) Returns requested styles for a DOM node identified by `nodeId`.Returns all media queries parsed by the rendering engine.static org.openqa.selenium.devtools.Command<List<PlatformFontUsage>>
getPlatformFontsForNode
(NodeId nodeId) Requests information about platform fonts which we used to render child TextNodes in the given node.static org.openqa.selenium.devtools.Command<String>
getStyleSheetText
(StyleSheetId styleSheetId) Returns the current textual content for a stylesheet.static org.openqa.selenium.devtools.Event<Void>
resolveValues
(List<String> values, NodeId nodeId, Optional<String> propertyName, Optional<PseudoType> pseudoType, Optional<String> pseudoIdentifier) Resolve the specified values in the context of the provided element.static org.openqa.selenium.devtools.Command<CSSContainerQuery>
setContainerQueryText
(StyleSheetId styleSheetId, SourceRange range, String text) Modifies the expression of a container query.static org.openqa.selenium.devtools.Command<Void>
setEffectivePropertyValueForNode
(NodeId nodeId, String propertyName, String value) Find a rule with the given active property for the given node and set the new value for this propertystatic org.openqa.selenium.devtools.Command<Value>
setKeyframeKey
(StyleSheetId styleSheetId, SourceRange range, String keyText) Modifies the keyframe rule key text.static org.openqa.selenium.devtools.Command<Void>
setLocalFontsEnabled
(Boolean enabled) Enables/disables rendering of local CSS fonts (enabled by default).static org.openqa.selenium.devtools.Command<CSSMedia>
setMediaText
(StyleSheetId styleSheetId, SourceRange range, String text) Modifies the rule selector.static org.openqa.selenium.devtools.Command<Value>
setPropertyRulePropertyName
(StyleSheetId styleSheetId, SourceRange range, String propertyName) Modifies the property rule property name.static org.openqa.selenium.devtools.Command<SelectorList>
setRuleSelector
(StyleSheetId styleSheetId, SourceRange range, String selector) Modifies the rule selector.static org.openqa.selenium.devtools.Command<CSSScope>
setScopeText
(StyleSheetId styleSheetId, SourceRange range, String text) Modifies the expression of a scope at-rule.static org.openqa.selenium.devtools.Command<String>
setStyleSheetText
(StyleSheetId styleSheetId, String text) Sets the new stylesheet text.setStyleTexts
(List<StyleDeclarationEdit> edits, Optional<NodeId> nodeForPropertySyntaxValidation) Applies specified style edits one after another in the given order.static org.openqa.selenium.devtools.Command<CSSSupports>
setSupportsText
(StyleSheetId styleSheetId, SourceRange range, String text) Modifies the expression of a supports at-rule.static org.openqa.selenium.devtools.Command<Void>
Enables the selector recording.Stop tracking rule usage and return the list of rules that were used since last call to `takeCoverageDelta` (or since start of coverage instrumentation).static org.openqa.selenium.devtools.Event<CSSStyleSheetHeader>
static org.openqa.selenium.devtools.Event<StyleSheetId>
static org.openqa.selenium.devtools.Event<StyleSheetId>
Polls the next batch of computed style updates.static org.openqa.selenium.devtools.Command<CSS.TakeCoverageDeltaResponse>
Obtain list of rules that became used since last call to this method (or since start of coverage instrumentation).static org.openqa.selenium.devtools.Command<Void>
trackComputedStyleUpdates
(List<CSSComputedStyleProperty> propertiesToTrack) Starts tracking the given computed styles for updates.static org.openqa.selenium.devtools.Command<Void>
Starts tracking the given node for the computed style updates and whenever the computed style is updated for node, it queues a `computedStyleUpdated` event with throttling.
-
Constructor Details
-
CSS
public CSS()
-
-
Method Details
-
addRule
public static org.openqa.selenium.devtools.Command<CSSRule> addRule(StyleSheetId styleSheetId, String ruleText, SourceRange location, Optional<NodeId> nodeForPropertySyntaxValidation) Inserts a new rule with the given `ruleText` in a stylesheet with given `styleSheetId`, at the position specified by `location`. -
collectClassNames
public static org.openqa.selenium.devtools.Command<List<String>> collectClassNames(StyleSheetId styleSheetId) Returns all class names from specified stylesheet. -
createStyleSheet
Creates a new special "via-inspector" stylesheet in the frame with given `frameId`. -
disable
Disables the CSS agent for the given page. -
enable
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. -
forcePseudoState
public static org.openqa.selenium.devtools.Command<Void> forcePseudoState(NodeId nodeId, List<String> forcedPseudoClasses) Ensures that the given node will have specified pseudo-classes whenever its style is computed by the browser. -
forceStartingStyle
public static org.openqa.selenium.devtools.Command<Void> forceStartingStyle(NodeId nodeId, Boolean forced) Ensures that the given node is in its starting-style state. -
getBackgroundColors
public static org.openqa.selenium.devtools.Command<CSS.GetBackgroundColorsResponse> getBackgroundColors(NodeId nodeId) -
getComputedStyleForNode
public static org.openqa.selenium.devtools.Command<List<CSSComputedStyleProperty>> getComputedStyleForNode(NodeId nodeId) Returns the computed style for a DOM node identified by `nodeId`. -
resolveValues
public static org.openqa.selenium.devtools.Command<List<String>> resolveValues(List<String> values, NodeId nodeId, Optional<String> propertyName, Optional<PseudoType> pseudoType, Optional<String> pseudoIdentifier) Resolve the specified values in the context of the provided element. For example, a value of '1em' is evaluated according to the computed 'font-size' of the element and a value 'calc(1px + 2px)' will be resolved to '3px'. -
getLonghandProperties
@Beta public static org.openqa.selenium.devtools.Command<List<CSSProperty>> getLonghandProperties(String shorthandName, String value) -
getInlineStylesForNode
public static org.openqa.selenium.devtools.Command<CSS.GetInlineStylesForNodeResponse> getInlineStylesForNode(NodeId nodeId) Returns the styles defined inline (explicitly in the "style" attribute and implicitly, using DOM attributes) for a DOM node identified by `nodeId`. -
getAnimatedStylesForNode
@Beta public static org.openqa.selenium.devtools.Command<CSS.GetAnimatedStylesForNodeResponse> getAnimatedStylesForNode(NodeId nodeId) Returns the styles coming from animations & transitions including the animation & transition styles coming from inheritance chain. -
getMatchedStylesForNode
public static org.openqa.selenium.devtools.Command<CSS.GetMatchedStylesForNodeResponse> getMatchedStylesForNode(NodeId nodeId) Returns requested styles for a DOM node identified by `nodeId`. -
getMediaQueries
Returns all media queries parsed by the rendering engine. -
getPlatformFontsForNode
public static org.openqa.selenium.devtools.Command<List<PlatformFontUsage>> getPlatformFontsForNode(NodeId nodeId) Requests information about platform fonts which we used to render child TextNodes in the given node. -
getStyleSheetText
public static org.openqa.selenium.devtools.Command<String> getStyleSheetText(StyleSheetId styleSheetId) Returns the current textual content for a stylesheet. -
getLayersForNode
@Beta public static org.openqa.selenium.devtools.Command<CSSLayerData> getLayersForNode(NodeId nodeId) 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. -
getLocationForSelector
@Beta public static org.openqa.selenium.devtools.Command<List<SourceRange>> getLocationForSelector(StyleSheetId styleSheetId, String selectorText) Given a CSS selector text and a style sheet ID, getLocationForSelector returns an array of locations of the CSS selector in the style sheet. -
trackComputedStyleUpdatesForNode
@Beta public static org.openqa.selenium.devtools.Command<Void> trackComputedStyleUpdatesForNode(Optional<NodeId> nodeId) Starts tracking the given node for the computed style updates and whenever the computed style is updated for node, it queues a `computedStyleUpdated` event with throttling. There can only be 1 node tracked for computed style updates so passing a new node id removes tracking from the previous node. Pass `undefined` to disable tracking. -
trackComputedStyleUpdates
@Beta public static org.openqa.selenium.devtools.Command<Void> trackComputedStyleUpdates(List<CSSComputedStyleProperty> propertiesToTrack) 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. -
takeComputedStyleUpdates
Polls the next batch of computed style updates. -
setEffectivePropertyValueForNode
public static org.openqa.selenium.devtools.Command<Void> setEffectivePropertyValueForNode(NodeId nodeId, String propertyName, String value) Find a rule with the given active property for the given node and set the new value for this property -
setPropertyRulePropertyName
public static org.openqa.selenium.devtools.Command<Value> setPropertyRulePropertyName(StyleSheetId styleSheetId, SourceRange range, String propertyName) Modifies the property rule property name. -
setKeyframeKey
public static org.openqa.selenium.devtools.Command<Value> setKeyframeKey(StyleSheetId styleSheetId, SourceRange range, String keyText) Modifies the keyframe rule key text. -
setMediaText
public static org.openqa.selenium.devtools.Command<CSSMedia> setMediaText(StyleSheetId styleSheetId, SourceRange range, String text) Modifies the rule selector. -
setContainerQueryText
@Beta public static org.openqa.selenium.devtools.Command<CSSContainerQuery> setContainerQueryText(StyleSheetId styleSheetId, SourceRange range, String text) Modifies the expression of a container query. -
setSupportsText
@Beta public static org.openqa.selenium.devtools.Command<CSSSupports> setSupportsText(StyleSheetId styleSheetId, SourceRange range, String text) Modifies the expression of a supports at-rule. -
setScopeText
@Beta public static org.openqa.selenium.devtools.Command<CSSScope> setScopeText(StyleSheetId styleSheetId, SourceRange range, String text) Modifies the expression of a scope at-rule. -
setRuleSelector
public static org.openqa.selenium.devtools.Command<SelectorList> setRuleSelector(StyleSheetId styleSheetId, SourceRange range, String selector) Modifies the rule selector. -
setStyleSheetText
public static org.openqa.selenium.devtools.Command<String> setStyleSheetText(StyleSheetId styleSheetId, String text) Sets the new stylesheet text. -
setStyleTexts
public static org.openqa.selenium.devtools.Command<List<CSSStyle>> setStyleTexts(List<StyleDeclarationEdit> edits, Optional<NodeId> nodeForPropertySyntaxValidation) Applies specified style edits one after another in the given order. -
startRuleUsageTracking
Enables the selector recording. -
stopRuleUsageTracking
Stop tracking rule usage and return the list of rules that were used since last call to `takeCoverageDelta` (or since start of coverage instrumentation). -
takeCoverageDelta
public static org.openqa.selenium.devtools.Command<CSS.TakeCoverageDeltaResponse> takeCoverageDelta()Obtain list of rules that became used since last call to this method (or since start of coverage instrumentation). -
setLocalFontsEnabled
@Beta public static org.openqa.selenium.devtools.Command<Void> setLocalFontsEnabled(Boolean enabled) Enables/disables rendering of local CSS fonts (enabled by default). -
fontsUpdated
-
mediaQueryResultChanged
-
styleSheetAdded
-
styleSheetChanged
-
styleSheetRemoved
-
computedStyleUpdated
-