playwright-ui5 1.6.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -21
- package/dist/browser/xpath.js +31 -25
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -81,21 +81,6 @@ in this case, `//sap.m.Button[@id='foo']` will work, but `//sap.m.Button[@text='
|
|
|
81
81
|
|
|
82
82
|
the XML view matches the control tree from the [ui5 diagnostics window](https://sapui5.hana.ondemand.com/sdk/#/topic/04b75eae78ef4bae9b40cd7540ae8bdc) and the [ui5 inspector chrome extension](https://chromewebstore.google.com/detail/ui5-inspector/bebecogbafbighhaildooiibipcnbngo), so we recommend using one of these when working with the ui5 xpath selector engine.
|
|
83
83
|
|
|
84
|
-
#### the root node
|
|
85
|
-
|
|
86
|
-
since the ui5 control tree can have multiple root nodes, the xpath selector engine wraps `sap-ui-area` nodes inside a `root` node:
|
|
87
|
-
|
|
88
|
-
```xml
|
|
89
|
-
<root>
|
|
90
|
-
<sap-ui-area id="sap-ui-static">
|
|
91
|
-
<sap.m.Page id="__page0">
|
|
92
|
-
<sap.m.Button id="foo"></sap.m.Button>
|
|
93
|
-
</sap.m.Page>
|
|
94
|
-
</sap-ui-area>
|
|
95
|
-
<sap-ui-area id="canvas">
|
|
96
|
-
</root>
|
|
97
|
-
```
|
|
98
|
-
|
|
99
84
|
#### API
|
|
100
85
|
|
|
101
86
|
the following xpath functions are available in the `ui5:` namespace:
|
|
@@ -119,7 +104,7 @@ gets the value for the property with the specified name from the specified eleme
|
|
|
119
104
|
raises an exception containining the XML control tree with the specified element as the root. this function is only intended for debugging purposes.
|
|
120
105
|
|
|
121
106
|
```xpath
|
|
122
|
-
ui5:debug-xml(
|
|
107
|
+
ui5:debug-xml(/*)
|
|
123
108
|
```
|
|
124
109
|
|
|
125
110
|
this will throw an exception containing the entire control tree for the page in XML format:
|
|
@@ -127,9 +112,7 @@ this will throw an exception containing the entire control tree for the page in
|
|
|
127
112
|
```
|
|
128
113
|
playwright-ui5 debug-xml function was called. here is the XML element tree:
|
|
129
114
|
|
|
130
|
-
<
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
</sap-ui-area>
|
|
134
|
-
</root>
|
|
115
|
+
<sap-ui-area id="sap-ui-static">
|
|
116
|
+
<!-- ... -->
|
|
117
|
+
</sap-ui-area>
|
|
135
118
|
```
|
package/dist/browser/xpath.js
CHANGED
|
@@ -29053,11 +29053,8 @@ var createTreeModelNodes = (node) => {
|
|
|
29053
29053
|
inner(node, result);
|
|
29054
29054
|
return result;
|
|
29055
29055
|
};
|
|
29056
|
-
var
|
|
29056
|
+
var createXmlFromTreeNode = (treeModelNode) => {
|
|
29057
29057
|
let xml = (0, import_xmlbuilder2.create)({ version: "1.0" });
|
|
29058
|
-
if (treeModelNodes[0]?.name === "sap-ui-area") {
|
|
29059
|
-
xml = xml.ele("root");
|
|
29060
|
-
}
|
|
29061
29058
|
const inner = (nodes) => {
|
|
29062
29059
|
nodes.forEach((node) => {
|
|
29063
29060
|
xml = xml.ele(node.name, { id: node.id });
|
|
@@ -29065,10 +29062,10 @@ var createXmlFromTreeNodes = (treeModelNodes) => {
|
|
|
29065
29062
|
xml = xml.up();
|
|
29066
29063
|
});
|
|
29067
29064
|
};
|
|
29068
|
-
inner(
|
|
29065
|
+
inner([treeModelNode]);
|
|
29069
29066
|
return xml.end({ prettyPrint: true });
|
|
29070
29067
|
};
|
|
29071
|
-
var createXml = (nodeElement) =>
|
|
29068
|
+
var createXml = (nodeElement) => createTreeModelNodes(nodeElement).map(createXmlFromTreeNode);
|
|
29072
29069
|
var namespaceURI = "ui5";
|
|
29073
29070
|
registerCustomXPathFunction(
|
|
29074
29071
|
{ namespaceURI, localName: "property" },
|
|
@@ -29106,20 +29103,26 @@ ${element.outerHTML}`
|
|
|
29106
29103
|
var options = {
|
|
29107
29104
|
namespaceResolver: (prefix) => prefix === namespaceURI ? prefix : null
|
|
29108
29105
|
};
|
|
29109
|
-
var
|
|
29110
|
-
var
|
|
29111
|
-
var matchXmlElementToHtmlElement = (
|
|
29106
|
+
var getRootElements = (htmlNode) => Array.from(htmlNode.childNodes).filter((childNode) => childNode instanceof Element);
|
|
29107
|
+
var createXmlDoms = (node) => createXml(node).map((xml) => new DOMParser().parseFromString(xml, "text/xml"));
|
|
29108
|
+
var matchXmlElementToHtmlElement = (htmlRoot, xmlElement) => {
|
|
29109
|
+
const result = htmlRoot.querySelector(`[id='${xmlElement.id}']`);
|
|
29110
|
+
if (result === null) {
|
|
29111
|
+
return [];
|
|
29112
|
+
}
|
|
29113
|
+
return [result];
|
|
29114
|
+
};
|
|
29112
29115
|
var xpath_default = {
|
|
29113
29116
|
queryAll: (root, selector) => {
|
|
29114
29117
|
try {
|
|
29115
29118
|
if (!isUi5()) {
|
|
29116
29119
|
return [];
|
|
29117
29120
|
}
|
|
29118
|
-
|
|
29119
|
-
|
|
29120
|
-
|
|
29121
|
-
|
|
29122
|
-
|
|
29121
|
+
return getRootElements(root).flatMap(
|
|
29122
|
+
(node) => createXmlDoms(node).flatMap(
|
|
29123
|
+
(xmlDom) => evaluateXPathToNodes(selector, xmlDom, null, null, options)
|
|
29124
|
+
).flatMap((element) => matchXmlElementToHtmlElement(root, element))
|
|
29125
|
+
);
|
|
29123
29126
|
} catch (e4) {
|
|
29124
29127
|
throw new Ui5SelectorEngineError(selector, e4);
|
|
29125
29128
|
}
|
|
@@ -29129,18 +29132,21 @@ var xpath_default = {
|
|
|
29129
29132
|
if (!isUi5()) {
|
|
29130
29133
|
return void 0;
|
|
29131
29134
|
}
|
|
29132
|
-
const node
|
|
29133
|
-
|
|
29134
|
-
|
|
29135
|
+
for (const node of getRootElements(root)) {
|
|
29136
|
+
for (const xmlDom of createXmlDoms(node)) {
|
|
29137
|
+
const result = evaluateXPathToFirstNode(
|
|
29138
|
+
selector,
|
|
29139
|
+
xmlDom,
|
|
29140
|
+
null,
|
|
29141
|
+
null,
|
|
29142
|
+
options
|
|
29143
|
+
);
|
|
29144
|
+
if (result) {
|
|
29145
|
+
return matchXmlElementToHtmlElement(root, result)[0];
|
|
29146
|
+
}
|
|
29147
|
+
}
|
|
29135
29148
|
}
|
|
29136
|
-
|
|
29137
|
-
selector,
|
|
29138
|
-
createXmlDom(node),
|
|
29139
|
-
null,
|
|
29140
|
-
null,
|
|
29141
|
-
options
|
|
29142
|
-
);
|
|
29143
|
-
return result ? matchXmlElementToHtmlElement(root, result) : void 0;
|
|
29149
|
+
return void 0;
|
|
29144
29150
|
} catch (e4) {
|
|
29145
29151
|
throw new Ui5SelectorEngineError(selector, e4);
|
|
29146
29152
|
}
|