Package org.openqa.selenium.devtools.css
Class CSS
- java.lang.Object
-
- org.openqa.selenium.devtools.css.CSS
-
@Beta public class CSS extends java.lang.Object
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 Classes Modifier and Type Class Description static class
CSS.GetBackgroundColorsResponse
static class
CSS.GetInlineStylesForNodeResponse
static class
CSS.GetMatchedStylesForNodeResponse
-
Constructor Summary
Constructors Constructor Description CSS()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Command<CSSRule>
addRule(StyleSheetId styleSheetId, java.lang.String ruleText, SourceRange location)
Inserts a new rule with the given `ruleText` in a stylesheet with given `styleSheetId`, at the position specified by `location`.static Command<java.util.List<java.lang.String>>
collectClassNames(StyleSheetId styleSheetId)
Returns all class names from specified stylesheet.static Command<StyleSheetId>
createStyleSheet(FrameId frameId)
Creates a new special "via-inspector" stylesheet in the frame with given `frameId`.static Command<java.lang.Void>
disable()
Disables the CSS agent for the given page.static Command<java.lang.Void>
enable()
Enables the CSS agent for the given page.static Event<FontFace>
fontsUpdated()
static Command<java.lang.Void>
forcePseudoState(NodeId nodeId, java.util.List<java.lang.String> forcedPseudoClasses)
Ensures that the given node will have specified pseudo-classes whenever its style is computed by the browser.static Command<CSS.GetBackgroundColorsResponse>
getBackgroundColors(NodeId nodeId)
static Command<java.util.List<CSSComputedStyleProperty>>
getComputedStyleForNode(NodeId nodeId)
Returns the computed style for a DOM node identified by `nodeId`.static 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 Command<CSS.GetMatchedStylesForNodeResponse>
getMatchedStylesForNode(NodeId nodeId)
Returns requested styles for a DOM node identified by `nodeId`.static Command<java.util.List<CSSMedia>>
getMediaQueries()
Returns all media queries parsed by the rendering engine.static Command<java.util.List<PlatformFontUsage>>
getPlatformFontsForNode(NodeId nodeId)
Requests information about platform fonts which we used to render child TextNodes in the given node.static Command<java.lang.String>
getStyleSheetText(StyleSheetId styleSheetId)
Returns the current textual content for a stylesheet.static Event<java.lang.Void>
mediaQueryResultChanged()
static Command<java.lang.Void>
setEffectivePropertyValueForNode(NodeId nodeId, java.lang.String propertyName, java.lang.String value)
Find a rule with the given active property for the given node and set the new value for this propertystatic Command<Value>
setKeyframeKey(StyleSheetId styleSheetId, SourceRange range, java.lang.String keyText)
Modifies the keyframe rule key text.static Command<CSSMedia>
setMediaText(StyleSheetId styleSheetId, SourceRange range, java.lang.String text)
Modifies the rule selector.static Command<SelectorList>
setRuleSelector(StyleSheetId styleSheetId, SourceRange range, java.lang.String selector)
Modifies the rule selector.static Command<java.lang.String>
setStyleSheetText(StyleSheetId styleSheetId, java.lang.String text)
Sets the new stylesheet text.static Command<java.util.List<CSSStyle>>
setStyleTexts(java.util.List<StyleDeclarationEdit> edits)
Applies specified style edits one after another in the given order.static Command<java.lang.Void>
startRuleUsageTracking()
Enables the selector recording.static Command<java.util.List<RuleUsage>>
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)static Event<CSSStyleSheetHeader>
styleSheetAdded()
static Event<StyleSheetId>
styleSheetChanged()
static Event<StyleSheetId>
styleSheetRemoved()
static Command<java.util.List<RuleUsage>>
takeCoverageDelta()
Obtain list of rules that became used since last call to this method (or since start of coverage instrumentation)
-
-
-
Method Detail
-
addRule
public static Command<CSSRule> addRule(StyleSheetId styleSheetId, java.lang.String ruleText, SourceRange location)
Inserts a new rule with the given `ruleText` in a stylesheet with given `styleSheetId`, at the position specified by `location`.
-
collectClassNames
public static Command<java.util.List<java.lang.String>> collectClassNames(StyleSheetId styleSheetId)
Returns all class names from specified stylesheet.
-
createStyleSheet
public static Command<StyleSheetId> createStyleSheet(FrameId frameId)
Creates a new special "via-inspector" stylesheet in the frame with given `frameId`.
-
disable
public static Command<java.lang.Void> disable()
Disables the CSS agent for the given page.
-
enable
public static Command<java.lang.Void> 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 Command<java.lang.Void> forcePseudoState(NodeId nodeId, java.util.List<java.lang.String> forcedPseudoClasses)
Ensures that the given node will have specified pseudo-classes whenever its style is computed by the browser.
-
getBackgroundColors
public static Command<CSS.GetBackgroundColorsResponse> getBackgroundColors(NodeId nodeId)
-
getComputedStyleForNode
public static Command<java.util.List<CSSComputedStyleProperty>> getComputedStyleForNode(NodeId nodeId)
Returns the computed style for a DOM node identified by `nodeId`.
-
getInlineStylesForNode
public static 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`.
-
getMatchedStylesForNode
public static Command<CSS.GetMatchedStylesForNodeResponse> getMatchedStylesForNode(NodeId nodeId)
Returns requested styles for a DOM node identified by `nodeId`.
-
getMediaQueries
public static Command<java.util.List<CSSMedia>> getMediaQueries()
Returns all media queries parsed by the rendering engine.
-
getPlatformFontsForNode
public static Command<java.util.List<PlatformFontUsage>> getPlatformFontsForNode(NodeId nodeId)
Requests information about platform fonts which we used to render child TextNodes in the given node.
-
getStyleSheetText
public static Command<java.lang.String> getStyleSheetText(StyleSheetId styleSheetId)
Returns the current textual content for a stylesheet.
-
setEffectivePropertyValueForNode
public static Command<java.lang.Void> setEffectivePropertyValueForNode(NodeId nodeId, java.lang.String propertyName, java.lang.String value)
Find a rule with the given active property for the given node and set the new value for this property
-
setKeyframeKey
public static Command<Value> setKeyframeKey(StyleSheetId styleSheetId, SourceRange range, java.lang.String keyText)
Modifies the keyframe rule key text.
-
setMediaText
public static Command<CSSMedia> setMediaText(StyleSheetId styleSheetId, SourceRange range, java.lang.String text)
Modifies the rule selector.
-
setRuleSelector
public static Command<SelectorList> setRuleSelector(StyleSheetId styleSheetId, SourceRange range, java.lang.String selector)
Modifies the rule selector.
-
setStyleSheetText
public static Command<java.lang.String> setStyleSheetText(StyleSheetId styleSheetId, java.lang.String text)
Sets the new stylesheet text.
-
setStyleTexts
public static Command<java.util.List<CSSStyle>> setStyleTexts(java.util.List<StyleDeclarationEdit> edits)
Applies specified style edits one after another in the given order.
-
startRuleUsageTracking
public static Command<java.lang.Void> startRuleUsageTracking()
Enables the selector recording.
-
stopRuleUsageTracking
public static Command<java.util.List<RuleUsage>> 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 Command<java.util.List<RuleUsage>> takeCoverageDelta()
Obtain list of rules that became used since last call to this method (or since start of coverage instrumentation)
-
mediaQueryResultChanged
public static Event<java.lang.Void> mediaQueryResultChanged()
-
styleSheetAdded
public static Event<CSSStyleSheetHeader> styleSheetAdded()
-
styleSheetChanged
public static Event<StyleSheetId> styleSheetChanged()
-
styleSheetRemoved
public static Event<StyleSheetId> styleSheetRemoved()
-
-