diff options
author | Matthew Sotoudeh <masotoudeh@ucdavis.edu> | 2020-09-03 15:09:16 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-03 15:09:16 -0700 |
commit | 0f54f5a46c5883afcb0b5bb9d4eafc44449098be (patch) | |
tree | cecfe97df202a95a934e19a2b110fa027a6b9f55 | |
parent | e8ffe5e7bb1a9983a39eac21389867dd1aa0cbfe (diff) | |
parent | fd1ff4b4d6517dab0936c64556ca3823ba573f78 (diff) |
Merge pull request #4 from matthewsot/matthew-add-link
Added docs.insertLink(target, text)
-rw-r--r-- | docs.js | 9 | ||||
-rw-r--r-- | test.js | 4 |
2 files changed, 13 insertions, 0 deletions
@@ -161,6 +161,15 @@ docs.toggleBold = function () { docs.pressKey(66, true, false); }; +// Inserts a link with the given text. +docs.insertLink = function (target, text) { + docs.pressButton($("[aria-label='Insert link (Ctrl+K)']")[0]); + $("[aria-label='Paste a link, or search']")[0].value = target; + $(".docs-link-insertlinkbubble-text.jfk-textinput.label-input-label")[0].value = text; + $("[aria-label='Paste a link, or search']")[0].dispatchEvent(new CustomEvent("input")); + docs.pressButton($(".docs-link-insertlinkbubble-buttonbar > div")[0]); +}; + /*********** MENU OPTIONS ***********/ docs.undo = function () { docs.pressButton($("[aria-label='Undo u']")[0]); @@ -60,6 +60,10 @@ docs.keydown = async function (e) { docs.pasteText("Back to normal.\n"); await sleep(500); + docs.insertLink("https://example.com/", "This should be a link to https://example.com/"); + docs.pasteText("Back to normal.\n"); + await sleep(500); + docs.pasteText("A few tests require user input:\n" + "1) Select something (or not) and press alt+s to " + "check the selection methods.\n" + |