Skip to content

Commit

Permalink
refactoring tinymce robot test
Browse files Browse the repository at this point in the history
  • Loading branch information
1letter committed Nov 12, 2024
1 parent 7de02bd commit b3ae618
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions Products/CMFPlone/tests/robot/test_tinymce.robot
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
*** Settings *****************************************************************

Resource plone/app/robotframework/keywords.robot
Resource plone/app/robotframework/saucelabs.robot
Resource plone/app/robotframework/selenium.robot
Resource plone/app/robotframework/browser.robot

Library Remote ${PLONE_URL}/RobotRemote

Expand All @@ -28,8 +26,8 @@ Scenario: A page is opened to edit in TinyMCE
and insert link
and insert image

Wait For Then Click Element css=#form-buttons-save
Wait until page contains Changes saved
Click //*[@id="form-buttons-save"]
Get Text //body contains Changes saved


*** Keywords *****************************************************************
Expand All @@ -39,39 +37,41 @@ Scenario: A page is opened to edit in TinyMCE
an edited page
Create content type=Document title=${TITLE}
Go to ${PLONE_URL}/${PAGE_ID}/edit
Wait until page contains Edit Page
Get Text //body contains Edit Page

an uploaded image
Create content type=Image title=an-image

text inserted into wysiwyg
Wait Until Element Is Visible css=.tox-edit-area iframe
Select Frame css=.tox-edit-area iframe
Input text css=.mce-content-body foobar
UnSelect Frame
Fill text to tinymce editor Susi Sorglos and John Doe

insert link
Select Frame css=.tox-edit-area iframe
Execute Javascript function selectElementContents(el) {var range = document.createRange(); range.selectNodeContents(el); var sel = window.getSelection(); sel.removeAllRanges(); sel.addRange(range);} var el = document.getElementById("tinymce"); selectElementContents(el);
UnSelect Frame
Click Button css=button[aria-label="Insert/edit link"]
Click Button css=.pat-relateditems-container button.favorites
Click Link css=.pat-relateditems-container .favorites a.fav[href='/']
Wait Until Element Is Visible css=.pat-relateditems-result-select.selectable
Click Link css=.pat-relateditems-result-select.selectable
Click Button css=.modal-footer input[name="insert"]
Select Frame css=.tox-edit-area iframe
Execute Javascript window.getSelection().removeAllRanges()
UnSelect Frame
Wait Until Element Is Not Visible css=.modal-footer input[name="insert"]
Evaluate JavaScript //div[contains(@class, 'tox-edit-area')]//iframe
... (elem, args) => {
... const iframe_document = elem.contentDocument;
... const body = iframe_document.body;
... const p = body.firstChild;
... const range = new Range();
... range.setStart(p.firstChild, 5);
... range.setEnd(p.firstChild, 12);
... iframe_document.getSelection().removeAllRanges();
... iframe_document.getSelection().addRange(range);
... }
... all_elements=False
Click //button[@aria-label='Insert/edit link']
Wait For Condition Element States //div[@class="modal-content"] contains visible
Click //div[@class="modal-body"]//fieldset[@data-linktype="internal"]//button[contains(@class,"mode") and contains(@class,"browse")]
Click //a[@title="Go one level up"]
Click //a[contains(@class,"selectable") and @data-path="/test-folder"]
Click //div[contains(@class,"modal-footer")]//input[@name="insert"]

insert image
Click Button css=button[aria-label="Insert/edit image"]
Click Button css=.pat-relateditems-container button.favorites
Click Link css=.pat-relateditems-container .favorites a.fav[href='/']
Wait Until Element Is Visible css=.pat-relateditems-result-select.selectable
Click Link css=.pat-relateditems-result-select.selectable
Input Text css=.modal-body [name="title"] SomeTitle
Input Text css=.modal-body [name="alt"] SomeAlt
Click Button css=.modal-footer input[name="insert"]
Wait Until Element Is Not Visible css=.modal-footer input[name="insert"]
Click //button[@aria-label="Insert/edit image"]
Wait For Condition Element States //div[@class="modal-content"] contains visible
Click //div[@class="modal-body"]//fieldset[@data-linktype="image"]//button[contains(@class,"mode") and contains(@class,"browse")]
Click //a[@title="Go one level up"]
Wait For Condition Element States //div[@id="select2-drop"]//ul[@class="select2-results"] contains visible
Click //div[@id="select2-drop"]//ul[@class="select2-results"]//li/div/div/a[contains(@class,"selectable") and @data-path="/image"]
Type Text //div[contains(@class, 'modal-body')]//input[@name="title"] SomeTitle
Type Text //div[contains(@class, 'modal-body')]//input[@name="alt"] SomeAlt
Click //div[contains(@class, 'modal-footer')]//input[contains(@name, 'insert')]

0 comments on commit b3ae618

Please sign in to comment.