MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / lineFor

Function lineFor

javascript/selenium-webdriver/lib/accessibility_snapshot.js:131–152  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

129}
130
131function lineFor(node) {
132 if (node.role === 'text') {
133 return `- text: ${node.name}`
134 }
135 let out = `- ${node.role}`
136 if (node.name !== '') {
137 out += ` ${quote(node.name)}`
138 }
139 for (const key of STATE_ORDER) {
140 if (!(key in node.states)) continue
141 const state = node.states[key]
142 if (state === true) {
143 out += ` [${key}]`
144 } else if (state !== false) {
145 out += ` [${key}=${state}]`
146 }
147 }
148 if (node.value) {
149 out += `: ${oneLine(node.value)}`
150 }
151 return out
152}
153
154function quote(name) {
155 return '"' + name.replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"'

Callers 1

linesFunction · 0.85

Calls 2

quoteFunction · 0.70
oneLineFunction · 0.70

Tested by

no test coverage detected