From 1719fe7561dc55f8ca5d44b1bf48661cbd866c78 Mon Sep 17 00:00:00 2001 From: 1letter <1letter@gmx.de> Date: Fri, 13 Sep 2024 08:28:28 +0200 Subject: [PATCH 1/6] port robot test to use only browser library --- .../tests/robot/test_translate_content.robot | 67 +++++++------------ 1 file changed, 26 insertions(+), 41 deletions(-) diff --git a/src/plone/app/multilingual/tests/robot/test_translate_content.robot b/src/plone/app/multilingual/tests/robot/test_translate_content.robot index 6c3a9d205..b7410ecd8 100644 --- a/src/plone/app/multilingual/tests/robot/test_translate_content.robot +++ b/src/plone/app/multilingual/tests/robot/test_translate_content.robot @@ -1,16 +1,13 @@ *** 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 +Library Remote ${PLONE_URL}/RobotRemote -Test Setup Run Keywords Plone test setup -Test Teardown Run keywords Plone test teardown +Test Setup Run Keywords Plone test setup +Test Teardown Run keywords Plone test teardown - -*** Test Cases *** +*** Test cases *** Scenario: As an editor I can translate a document Given a site owner @@ -24,56 +21,44 @@ Scenario: As a visitor I can view the translation When I switch to Catalan Then I can view the document in Catalan - *** Keywords *** +Pause + [Documentation] Visually pause test execution with interactive dialog by + ... importing **Dialogs**-library and calling its + ... **Pause Execution**-keyword. + Import library Dialogs + Pause execution + # Given a site owner Enable autologin as Manager -a visitor - Disable autologin - a document in English - Create content type=Document - ... container=/${PLONE_SITE_ID}/en/ - ... id=an-english-document - ... title=An English Document + Create content type=Document container=/${PLONE_SITE_ID}/en/ id=an-english-document title=An English Document a document in English with Catalan translation - ${uid} = Create content type=Document - ... container=/${PLONE_SITE_ID}/en/ - ... id=an-english-document - ... title=An English Document - Create translation ${uid} ca - ... title=A Catalan Document - Go to ${PLONE_URL}/resolveuid/${uid} - Wait until page contains An English Document + ${uid}= Create content type=Document container=/${PLONE_SITE_ID}/en/ id=an-english-document title=An English Document + Create translation ${uid} ca title=A Catalan Document + Go to ${PLONE_URL}/resolveuid/${uid} + Get Element //h1[1][text()='An English Document'] # When I translate the document into Catalan - Go to ${PLONE_URL}/en/an-english-document/@@create_translation?language=ca - Capture page screenshot - Input Text form.widgets.IDublinCore.title A Catalan Document - Click Link Dates # workaround for of TinyMCE editor field problem - Capture page screenshot - Click button css=#form-buttons-save - - # Wait until page contains Element creat - # (Catalan translations not currently available) - - Wait until page contains A Catalan Document + Go to ${PLONE_URL}/en/an-english-document/@@create_translation?language=ca + Take screenshot + Type Text //input[@name="form.widgets.IDublinCore.title"] A Catalan Document + Take screenshot + Click //button[@id="form-buttons-save"] I switch to Catalan - Click Link xpath=//a[@title='Català'] - Wait until page contains A Catalan Document + Click //a[@title='Català'] + Get Element //h1[1][text()='A Catalan Document'] # Then I can view the document in Catalan - Page Should Contain Element - ... xpath=//h1[1][text()='A Catalan Document'] - Page Should Contain Element - ... xpath=//ul[@id='portal-languageselector']/li[contains(@class, 'currentLanguage')]/a[@title='Català'] + Get Element //h1[1][text()='A Catalan Document'] + Get Element //ul[@id='portal-languageselector']/li[contains(@class, 'currentLanguage')]/a[@title='Català'] From 0dc4a7272d7b33538b13caf7d5dc211efb7d6e98 Mon Sep 17 00:00:00 2001 From: 1letter <1letter@gmx.de> Date: Fri, 13 Sep 2024 09:14:54 +0200 Subject: [PATCH 2/6] port robot test to use browser library --- .../tests/robot/test_schemaeditor.robot | 63 +++++++++---------- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/src/plone/app/multilingual/tests/robot/test_schemaeditor.robot b/src/plone/app/multilingual/tests/robot/test_schemaeditor.robot index 0ce75781c..bda8cfc3c 100644 --- a/src/plone/app/multilingual/tests/robot/test_schemaeditor.robot +++ b/src/plone/app/multilingual/tests/robot/test_schemaeditor.robot @@ -1,16 +1,13 @@ *** 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 +Library Remote ${PLONE_URL}/RobotRemote -Test Setup Run Keywords Plone test setup -Test Teardown Run keywords Plone test teardown +Test Setup Run Keywords Plone test setup +Test Teardown Run keywords Plone test teardown - -*** Test Cases *** +*** Test cases *** Scenario: As a site owner I can see language independent field setting Given a site owner @@ -42,54 +39,54 @@ Scenario: As a site owner I can unset field from being language independent # Given a site owner - Enable autologin as Manager + Enable autologin as Manager a dexterity content type with a TTW field - Create content type Custom - Go to ${PLONE_URL}/dexterity-types/Custom/@@fields - Wait until page contains element css=body.template-fields + Create content type Custom + Go to ${PLONE_URL}/dexterity-types/Custom/@@fields + Get Element //body[contains(@class, "template-fields")] a dexterity content type field settings form - Go to ${PLONE_URL}/dexterity-types/Custom/@@fields - Go to ${PLONE_URL}/dexterity-types/Custom/custom - Wait until page contains Language independent field + Go to ${PLONE_URL}/dexterity-types/Custom/@@fields + Go to ${PLONE_URL}/dexterity-types/Custom/custom + Get Text //div[@id="form-widgets-IFieldLanguageIndependent-languageindependent"] contains Language independent field a dexterity content type with a language independent TTW field - Create content type Custom - Set field language independent Custom custom on - Go to ${PLONE_URL}/dexterity-types/Custom/@@fields - Wait until page contains element css=body.template-fields + Create content type Custom + Set field language independent Custom custom on + Go to ${PLONE_URL}/dexterity-types/Custom/@@fields + Get Element //body[contains(@class, "template-fields")] # When I open the field settings - Go to ${PLONE_URL}/dexterity-types/Custom/custom - Page should contain Language independent field + Go to ${PLONE_URL}/dexterity-types/Custom/custom + Get Text //div[@id="form-widgets-IFieldLanguageIndependent-languageindependent"] contains Language independent field I select the language independent field setting - Select checkbox form-widgets-IFieldLanguageIndependent-languageindependent-0 - Checkbox should be selected form-widgets-IFieldLanguageIndependent-languageindependent-0 + Check Checkbox //input[@id="form-widgets-IFieldLanguageIndependent-languageindependent-0"] + Get Checkbox State //input[@id="form-widgets-IFieldLanguageIndependent-languageindependent-0"] == checked I save the form - Wait until page contains element css=#form-buttons-save - Click button css=#form-buttons-save - Wait until keyword succeeds 1 10 Element should not be visible .plone-modal-wrapper + Get Element //*[@id="form-buttons-save"] + Click //*[@id="form-buttons-save"] + Get Element Count //div[contains(@class,"plone-modal-wrapper")] should be 0 I open the form again - Go to ${PLONE_URL}/dexterity-types/Custom/custom - Wait until page contains Language independent field + Go to ${PLONE_URL}/dexterity-types/Custom/custom + Get Text //div[@id="form-widgets-IFieldLanguageIndependent-languageindependent"] contains Language independent field I unselect the language independent field setting - Unselect checkbox form-widgets-IFieldLanguageIndependent-languageindependent-0 - Checkbox should not be selected form-widgets-IFieldLanguageIndependent-languageindependent-0 + Uncheck Checkbox //input[@id="form-widgets-IFieldLanguageIndependent-languageindependent-0"] + Get Checkbox State //input[@id="form-widgets-IFieldLanguageIndependent-languageindependent-0"] == unchecked # Then I can see the language independent field setting - Wait until page contains element id=form-widgets-IFieldLanguageIndependent-languageindependent-0 + Get Element //*[@id="form-widgets-IFieldLanguageIndependent-languageindependent-0"] the language independent field setting is selected - Checkbox should be selected form-widgets-IFieldLanguageIndependent-languageindependent-0 + Get Checkbox State //input[@id="form-widgets-IFieldLanguageIndependent-languageindependent-0"] == checked the language independent field setting is not selected - Checkbox should not be selected form-widgets-IFieldLanguageIndependent-languageindependent-0 + Get Checkbox State //input[@id="form-widgets-IFieldLanguageIndependent-languageindependent-0"] == unchecked From 9d1ca059fc9f9b29fd628632bbced5139ac2eaff Mon Sep 17 00:00:00 2001 From: 1letter <1letter@gmx.de> Date: Fri, 13 Sep 2024 09:16:24 +0200 Subject: [PATCH 3/6] remove unused keyword from robot test --- .../multilingual/tests/robot/test_translate_content.robot | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/plone/app/multilingual/tests/robot/test_translate_content.robot b/src/plone/app/multilingual/tests/robot/test_translate_content.robot index b7410ecd8..316062f25 100644 --- a/src/plone/app/multilingual/tests/robot/test_translate_content.robot +++ b/src/plone/app/multilingual/tests/robot/test_translate_content.robot @@ -23,13 +23,6 @@ Scenario: As a visitor I can view the translation *** Keywords *** -Pause - [Documentation] Visually pause test execution with interactive dialog by - ... importing **Dialogs**-library and calling its - ... **Pause Execution**-keyword. - Import library Dialogs - Pause execution - # Given a site owner From 76b13ac6a232e2b61445bd97afc83751d479df01 Mon Sep 17 00:00:00 2001 From: 1letter <1letter@gmx.de> Date: Fri, 13 Sep 2024 11:31:46 +0200 Subject: [PATCH 4/6] port robot test to use browser library --- .../tests/robot/test_add_translation.robot | 86 ++++++------------- 1 file changed, 27 insertions(+), 59 deletions(-) diff --git a/src/plone/app/multilingual/tests/robot/test_add_translation.robot b/src/plone/app/multilingual/tests/robot/test_add_translation.robot index 46a5b9ac6..236a49dde 100644 --- a/src/plone/app/multilingual/tests/robot/test_add_translation.robot +++ b/src/plone/app/multilingual/tests/robot/test_add_translation.robot @@ -1,14 +1,11 @@ *** Settings *** -Resource plone/app/robotframework/keywords.robot -Resource plone/app/robotframework/saucelabs.robot -Resource plone/app/robotframework/selenium.robot -Resource Products/CMFPlone/tests/robot/keywords.robot +Resource plone/app/robotframework/browser.robot -Library Remote ${PLONE_URL}/RobotRemote +Library Remote ${PLONE_URL}/RobotRemote -Test Setup Run Keywords Plone test setup -Test Teardown Run keywords Plone test teardown +Test Setup Run Keywords Plone test setup +Test Teardown Run keywords Plone test teardown *** Test Cases *** @@ -24,74 +21,45 @@ Scenario: As an editor I can add new translation *** Keywords *** -Setup test browser - Set Selenium speed 0.5s - Open test browser - Set window size 1200 900 - # Given a site owner - Enable autologin as Manager + Enable autologin as Manager a document in English - Create content type=Document - ... container=/${PLONE_SITE_ID}/en/ - ... id=an-english-document - ... title=An English Document + Create content type=Document container=/${PLONE_SITE_ID}/en/ id=an-english-document title=An English Document a document in Catalan - Create content type=Document - ... container=/${PLONE_SITE_ID}/ca/ - ... id=a-catalan-document - ... title=A Catalan Document + Create content type=Document container=/${PLONE_SITE_ID}/ca/ id=a-catalan-document title=A Catalan Document # When I view the Catalan document - Go to ${PLONE_URL}/ca/a-catalan-document - Wait until page contains A Catalan Document + Go to ${PLONE_URL}/ca/a-catalan-document + Get Element //h1[1][text()='A Catalan Document'] I link the document in English as a translation - Page should contain element css=#plone-contentmenu-multilingual a - Capture page screenshot - Element should be visible css=#plone-contentmenu-multilingual a - Click Element css=#plone-contentmenu-multilingual a - Wait until page contains element css=#_modify_translations - Wait until element is visible css=#_modify_translations - - Click Element css=#_modify_translations - Given patterns are loaded - Wait until page contains element css=#translations-overview .connectTranslationAction - - Click Element css=#translations-overview .connectTranslationAction - Wait until page contains element css=.select2-choices - Wait until element is visible css=.select2-choices - Click Element css=#formfield-form-widgets-content .pat-relateditems-container button.mode.search - Input Text css=#formfield-form-widgets-content .select2-input en - Wait until page contains element xpath=(//span[contains(., 'An English Document')]) - Wait until element is visible xpath=(//span[contains(., 'An English Document')]) - Click Element xpath=(//span[contains(., 'An English Document')]) - Wait until page contains An English Document - - # We need a complicated xpath, because for some reason a button with this id is there twice. - # The first one is hidden. - Click Element xpath=(//*[contains(@class, 'modal-footer')]//button[@id='form-buttons-connect_translation']) - Wait until page contains element xpath=(//h3[@class="translationTitle"]) - Sleep 5 - Wait until element is visible xpath=(//h3[@class="translationTitle"]) - Set Focus To Element xpath=(//*[@id="translations-overview"]//a[contains(@href,"a-catalan-document")]) - Click Element xpath=(//*[@id="translations-overview"]//a[contains(text(),'/plone/ca/a-catalan-document')]) - Wait until page contains A Catalan Document + Get Element //li[@id="plone-contentmenu-multilingual"]/a + Take Screenshot + Get Element States //li[@id="plone-contentmenu-multilingual"]/a contains visible + Click //li[@id="plone-contentmenu-multilingual"]/a + Get Element States //a[@id="_modify_translations"] contains visible + Click //a[@id="_modify_translations"] + Click //table[@id="translations-overview"]/tbody/tr[1]/td[3]/a[contains(@class,"connectTranslationAction")] + Click //div[@id="formfield-form-widgets-content"]//div[contains(@class,"pat-relateditems-container")]//button[contains(@class,"mode") and contains(@class,"search")] + Type Text //div[@id="formfield-form-widgets-content"]//input[contains(@class,"select2-input")] en + Click //span[contains(., 'An English Document')] + Click //*[contains(@class, 'modal-footer')]//button[@id='form-buttons-connect_translation'] + Get Text //table[@id="translations-overview"]/tbody/tr[1]/td[2]/h3[@class="translationTitle"] should be An English Document + Click //table[@id="translations-overview"]//a[contains(text(),'/plone/ca/a-catalan-document')] + Get Text //*[@id="content"]/header/h1 should be A Catalan Document I switch to English - Click Link xpath=//a[@title='English'] - Wait until page contains An English Document + Click //a[@title='English'] + Get Element //h1[1][contains(text(),'An English Document')] # Then I can view the document in English - Wait until page contains element - ... xpath=//h1[1][contains(text(),'English Document')] - Wait until page contains element - ... xpath=//ul[@id='portal-languageselector']/li[contains(@class, 'currentLanguage')]/a[@title='English'] + Get Element //h1[1][contains(text(),'English Document')] + Get Element //ul[@id='portal-languageselector']/li[contains(@class, 'currentLanguage')]/a[@title='English'] From a0980e68d5957a126efd70b40b0a4aea5831df67 Mon Sep 17 00:00:00 2001 From: 1letter <1letter@gmx.de> Date: Fri, 13 Sep 2024 11:35:52 +0200 Subject: [PATCH 5/6] add news --- news/459.tests | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/459.tests diff --git a/news/459.tests b/news/459.tests new file mode 100644 index 000000000..049473239 --- /dev/null +++ b/news/459.tests @@ -0,0 +1 @@ +port robot tests to use the browser library [@1letter] From 6a06ca51dc3e9834aa9ce4e83db360ca90863959 Mon Sep 17 00:00:00 2001 From: 1letter <1letter@gmx.de> Date: Fri, 13 Sep 2024 18:44:13 +0200 Subject: [PATCH 6/6] Update imports for test setup --- src/plone/app/multilingual/testing.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/plone/app/multilingual/testing.py b/src/plone/app/multilingual/testing.py index 9e587dae3..aa64c8413 100644 --- a/src/plone/app/multilingual/testing.py +++ b/src/plone/app/multilingual/testing.py @@ -18,7 +18,8 @@ from plone.dexterity.utils import iterSchemataForType from plone.rfc822 import constructMessageFromSchemata from plone.rfc822 import initializeObjectFromSchemata -from plone.testing import z2 +from plone.testing.layer import Layer +from plone.testing.zope import WSGI_SERVER_FIXTURE from plone.uuid.interfaces import IUUID from Products.CMFCore.utils import getToolByName from zope.configuration import xmlconfig @@ -156,7 +157,7 @@ def setUpPloneSite(self, portal): ) -class MultipleLanguagesLayer(z2.Layer): +class MultipleLanguagesLayer(Layer): defaultBases = (PLONE_APP_MULTILINGUAL_PRESET_FIXTURE,) @@ -257,7 +258,11 @@ def create_translation(self, *args, **kwargs): ) PLONE_APP_MULTILINGUAL_ROBOT_TESTING = FunctionalTesting( - bases=(MULTIPLE_LANGUAGES_LAYER, REMOTE_LIBRARY_BUNDLE_FIXTURE, z2.ZSERVER_FIXTURE), + bases=( + MULTIPLE_LANGUAGES_LAYER, + REMOTE_LIBRARY_BUNDLE_FIXTURE, + WSGI_SERVER_FIXTURE, + ), name="plone.app.multilingual:Robot", )