-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix tests and edge cases in jump to, diagnostics, highlighting, and rename #966
Fix tests and edge cases in jump to, diagnostics, highlighting, and rename #966
Conversation
- enh: class names will be applied on marks as needed - perf: empty marks won't be added - perf: elements wont be created if not needed
Problem: CodeMirror no longer tokenizers every variable, instead multiple tokens and even punctuation may be in the same text node. Many variables are also no longer syntax highlighted due to CM choices. The old selectors like: ${def} = Set Variable xpath:(//span[contains(@class, 'cm-atom')][contains(text(), 'foo')])[last()] do not work anymore. Attempt 1:Select any node within the line containg text using xpath ${def} = Set Variable xpath:(//div[contains(@class, 'cm-line')]//*[contains(text(), 'foo')])[last()] This worked... sometimes. The problem is that the cursor may point to a different part of the line and it was terribly flaky. Attempt 2:Select the text node using xpath ${def} = Set Variable xpath:(//div[contains(@class, 'cm-line')]//text()[contains(., 'text')])[last()] This did not work:
Initially I did not know why... Attempt 3:Select the node in JS Locate Last Token With Text
[Arguments] ${browser} ${locator} ${tag} ${constraints}
Execute JavaScript
... window.breadthFirstSearchReverse = function (nodes) {
... for (let n of nodes.toReversed()) {
... if (n.childNodes.length) {
... var result = window.breadthFirstSearchReverse([...n.childNodes]);
... if (result) {return result }
... } else if (n.textContent.match('${locator}')) {
... return n;
... }
... }
... }
${element}= Execute JavaScript
... return window.breadthFirstSearchReverse([...document.querySelectorAll('.cm-line')]);
[Return] ${element} with
Error. Oh, I know this error!
Attempt 4:I noticed CodeMirror adds ... } else if (n.textContent.match('${locator}')) {
... n.cmView = null;
... return n;
... } But still getting Attempt 5:What if we created an overlay which would be event-transparent and used that instead? ... const range = document.createRange();
... range.setStartBefore(n);
... range.setEndAfter(n);
... rect = range.getBoundingClientRect();
... cover.style.position = 'fixed';
... cover.style.background = 'red';
... cover.style.top = rect.top + 'px';
... cover.style.left = rect.left + 'px';
... cover.style.height = rect.height + 'px';
... cover.style.width = rect.width + 'px';
... covert.style.pointerEvents = 'none';
... document.body.appendChild(cover);
... return cover; Nope:
Attempt 6:What if I kept the pointer events but moved it underneath? ... covert.style.zIndex = -1; Nope:
Attempt 7:Ok, the text node is problematic, maybe I can just wrap it with a span an return that? ... wrapper = document.createElement('span');
... n.replaceWith(wrapper);
... wrapper.appendChild(n);
... return wrapper; Nope:
|
It looks this is a general limitation of Selenium (/with Firefox driver?), because even: ... return document.createTextNode('a'); leads to the |
Some other ideas:
|
@bollwyvl any suggestions, anything obvious I missed? |
References
Fixes #961
Code changes
Wait Until Page Contains Diagnostic
keywordUser-facing changes
Backwards-incompatible changes
None