Skip to content
Snippets Groups Projects
Commit 97b5c875 authored by Florian Bruhin's avatar Florian Bruhin
Browse files

Fix scrolling with newer pytest-html

parent aec91f99
No related branches found
No related tags found
No related merge requests found
...@@ -42,14 +42,10 @@ class ReportView(QWidget): ...@@ -42,14 +42,10 @@ class ReportView(QWidget):
self._textedit.moveCursor(QTextCursor.MoveOperation.End) self._textedit.moveCursor(QTextCursor.MoveOperation.End)
self._textedit.find(escaped_id, QTextDocument.FindFlag.FindBackward) self._textedit.find(escaped_id, QTextDocument.FindFlag.FindBackward)
def _js_callback(self, nodeid: str, nodeids: list[str]) -> None: def _js_callback(self, nodeid: str, success: bool) -> None:
if not nodeids: # success if success:
return return
logging.warning(f"Did not find node ID {nodeid} in report") logging.warning(f"Did not find node ID {nodeid} in report")
logging.debug("Considered:")
for e in nodeids:
logging.debug(f" {e}")
def _nodeid_to_html(self, nodeid: str) -> str: def _nodeid_to_html(self, nodeid: str) -> str:
"""Convert a node ID to the way it gets rendered in HTML.""" """Convert a node ID to the way it gets rendered in HTML."""
...@@ -62,19 +58,17 @@ class ReportView(QWidget): ...@@ -62,19 +58,17 @@ class ReportView(QWidget):
self._webview.page().runJavaScript( self._webview.page().runJavaScript(
""" """
(function () { (function () {
let nodeids = []; let elem = document.getElementById('%NODEID%');
if (elem === null) {
for (let elem of document.getElementsByClassName('col-name')) { elem = document.getElementById('%NODEID%::setup');
nodeids.push(elem.innerText); }
if (elem.innerText.replace('::setup', '') == '%NODEID%') {
elem.scrollIntoView(); if (elem !== null) {
// empty array returned: no error elem.scrollIntoView();
return []; return true;
}
} }
// error: return all IDs we considered return false;
return nodeids;
})(); })();
""".replace( """.replace(
"%NODEID%", nodeid "%NODEID%", nodeid
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment