Converts a CSS3 selector into Inspector Protocol NodeID.
A CSS3 Selector string pointing to a single HTML5 element.
If you are unfamiliar with CSS3 Selectors have a look in Finding the correct CSS3 Selector article.
Converts a CSS3 selector into Inspector Protocol NodeID.
Visual Basic |
---|
Public Function GetNodeID( _ ByVal Selector As String _ ) As String |
A CSS3 Selector string pointing to a single HTML5 element.
If you are unfamiliar with CSS3 Selectors have a look in Finding the correct CSS3 Selector article.
The NodeID string of the underlying HTML5 DOM Node.
Chromium DevTools Inspector Protocol methods require NodeID instead of CSS3 selectors.
This method provides an easy way to convert a CSS3 selector into a NodeID by hiding the underlying complexity.
Private Sub GetNodeStyles() Dim NodeID As String Dim JSON As String NodeID = WebKitX.GetNodeID("#mydiv") JSON = WebKitX.ExecDevToolsCommand("CSS.getMatchedStylesForNode", """nodeId"": " + NodeID, True) End Sub Private Sub WebKitX_OnDevToolsWebSocket(ByVal Data As String) On Error Resume Next If InStr(Data, "CSS.styleSheetAdded") > 0 Then Dim xDOM As Object Set xDOM = XML_DOM(JSONtoXML(Data)) StyleSheets.Add xDOM.selectSingleNode("//styleSheetId").Text, xDOM.selectSingleNode("//sourceURL").Text End If Err.Clear End Sub Public Function XML_DOM(Optional sAnyXML) As IXMLDOMDocument Dim xDOM As DOMDocument30 Set xDOM = New DOMDocument30 xDOM.Async = False xDOM.resolveExternals = False xDOM.validateOnParse = False If Not IsMissing(sAnyXML) Then If IsObject(sAnyXML) Then xDOM.Load sAnyXML ElseIf sAnyXML <> vbNullString Then If InStrB(sAnyXML, "<") Then xDOM.loadXML sAnyXML Else xDOM.Load sAnyXML End If End If End If xDOM.SetProperty "SelectionLanguage", "XPath" xDOM.SetProperty "SelectionNamespaces", vbNullString Set XML_DOM = xDOM End Function