Skip to content

Commit fef4b46

Browse files
author
Vasyl Vavrychuk
committed
fixed visualizer click not working due to find element problem
With introduction of Tidy one-to-one mapping beetwean actual and visualizer html xpathes disappeared. Overcome this by generating custom attribute.
1 parent 5c64525 commit fef4b46

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/webdriver/extension_qt/web_view_visualizer.cc

+5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ QWebViewVisualizerSourceCommand::QWebViewVisualizerSourceCommand(QWebViewCmdExec
2121
void QWebViewVisualizerSourceCommand::Execute(std::string* source, Error** error) {
2222
// Convert DOM tree to valid XML.
2323
const char* kSource =
24+
"var elements = document.getElementsByTagName('*');\n"
25+
"for (var index = 0; index < elements.length; index++) {\n"
26+
" var element = elements[index];\n"
27+
" element.setAttribute('data-viz-id', index);\n"
28+
"}\n"
2429
"var root = document.documentElement.cloneNode(true);\n"
2530
"var elements = root.getElementsByTagName('script');\n"
2631
"for (var index = 0; index < elements.length; index++) {\n"

web/webdriver-app.js

+3
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ function _getXPath(node, path) {
7373
}
7474

7575
function getXPath(node) {
76+
if (node.hasAttribute('data-viz-id'))
77+
return '//*[@data-viz-id=' + node.getAttribute('data-viz-id') + "]";
78+
7679
var path = _getXPath(node);
7780
return '/' + path.join('/');
7881
}

0 commit comments

Comments
 (0)