Sha256: 0d700e28441a39f6f488d35c53bd374ed00cf02717495a4619c11e8c42fba864
Contents?: true
Size: 1.33 KB
Versions: 4
Compression:
Stored size: 1.33 KB
Contents
<script> // TODO do we have to do this differently for turbo? $(document).ready(function() { enableKeyboardShortcuts(); }); function enableKeyboardShortcuts() { function keydown(event) { if (event.ctrlKey && event.shiftKey && event.key === 'A') { event.preventDefault(); generateAssertion(); } } document.addEventListener('keydown', keydown, false); function generateAssertion() { var text = selectedText(); if (text.trim().length > 0) { var action = "assert page.has_content?('" + text.replace("'", "\\\'") + "')"; var testingOutput = JSON.parse(sessionStorage.getItem("testingOutput")); var target = ""; var options = ""; testingOutput.push({action: action, target: target, options: options}); sessionStorage.setItem("testingOutput", JSON.stringify(testingOutput)); alert("Generated an assertion for \"" + selectedText() + "\". Type `flush` in the debugger console to add it to your test file."); } } function selectedText() { var text = ""; if (window.getSelection) { text = window.getSelection().toString(); } else if (document.selection && document.selection.type != "Control") { text = document.selection.createRange().text; } return text; } } </script>
Version data entries
4 entries across 4 versions & 1 rubygems