[TASK] Tweak of the Formhandler acceptance tests 68/48068/8
authorNikola Stojiljkovic <nikola.stojiljkovic@essentialdots.com>
Tue, 10 May 2016 14:36:43 +0000 (17:36 +0300)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 12 May 2016 14:55:44 +0000 (16:55 +0200)
Includes:
* Added testing of persistence
* Added tests for datetime fields
* Prevent random timeouts from affecting the test results
* Added displaying of modal with error message instead of an alert
  on trying to save a form with validation errors

The tests are stable using Selenium with Firefox. Using phantomjs gives
erratic results due to "QIODevice::write (QTcpSocket): device not open"
bug which randomly pops up.

Resolves: #76122
Releases: master
Change-Id: Ia0c06fc4dbd83e2373d33bb07c48559894fc3ec5
Reviewed-on: https://review.typo3.org/48068
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Resources/Public/JavaScript/FormEngineValidation.js
typo3/sysext/backend/Resources/Public/JavaScript/jsfunc.tbe_editor.js
typo3/sysext/core/Tests/Acceptance/Backend/Formhandler/ElementsBasicCest.php
typo3/sysext/core/Tests/Acceptance/Support/Helper/Formhandler.php

index 41c7f09..8ba8c8a 100644 (file)
@@ -131,13 +131,15 @@ define(['jquery', 'TYPO3/CMS/Backend/FormEngine'], function ($, FormEngine) {
                                $humanReadableField.val(value);
                        }
                }
-
                $humanReadableField.data('main-field', fieldName);
                $humanReadableField.data('config', config);
                $humanReadableField.on('change', function() {
                        FormEngineValidation.updateInputField($(this).attr('data-formengine-input-name'));
                });
                $humanReadableField.on('keyup', FormEngineValidation.validate);
+
+               // add the attribute so that acceptance tests can know when the field initialization has completed
+               $humanReadableField.attr('data-formengine-input-initialized', 'true');
        };
 
        /**
index 451f1ce..48d4dcf 100644 (file)
@@ -226,7 +226,24 @@ var TBE_EDITOR = {
                if (OK || sendAlert==-1) {
                        return true;
                } else {
-                       if (sendAlert) alert(TBE_EDITOR.labels.fieldsMissing);
+                       if (sendAlert) {
+                               var t = (opener != null && typeof opener.top.TYPO3 !== 'undefined' ? opener.top : top);
+                               t.TYPO3.Modal.confirm(
+                                       t.TYPO3.lang['alert'] || 'Alert',
+                                       TBE_EDITOR.labels.fieldsMissing,
+                                       t.TYPO3.Severity.error,
+                                       [
+                                               {
+                                                       text: t.TYPO3.lang['button.ok'] || 'OK',
+                                                       active: true,
+                                                       btnClass: 'btn-default',
+                                                       name: 'ok'
+                                               }
+                                       ]
+                               ).on('button.clicked', function(e) {
+                                       t.TYPO3.Modal.dismiss();
+                               });
+                       }
                        return false;
                }
        },
index 9720b91..d06d3f1 100644 (file)
@@ -44,217 +44,427 @@ class ElementsBasicCest
      */
     public function checkThatBrowserSideValidationsWorkAndSaveRecord(Admin $I, Formhandler $formhandler)
     {
-        $I->click(self::$listViewRecordSelector . ' a[data-original-title="Edit record"]');
+        $editRecordLinkCssPath = self::$listViewRecordSelector . ' a[data-original-title="Edit record"]';
+        $I->waitForElement($editRecordLinkCssPath, 30);
+        $I->click($editRecordLinkCssPath);
         $I->waitForText('Edit Form', 3, 'h1');
 
         $fieldTests = [
             'input_1' => [
-                [
-                    'This is a demo text with 2 numbers #!',
-                    'This is a demo text with 2 numbers #!',
-                ],
+                'tests' => [
+                    [
+                        'This is a demo text with 2 numbers #!',
+                        'This is a demo text with 2 numbers #!',
+                    ],
+                ],
+                'cleared' => [
+                    ''
+                ]
             ],
             'input_2, size=10' => [
-                [
-                    'This is a demo text with 2 numbers #!',
-                    'This is a demo text with 2 numbers #!',
-                ],
+                'tests' => [
+                    [
+                        'This is a demo text with 2 numbers #!',
+                        'This is a demo text with 2 numbers #!',
+                    ],
+                ],
+                'cleared' => [
+                    ''
+                ]
             ],
             'input_3 max=4' => [
-                [
-                    'Kasper',
-                    'Kasp',
-                ],
+                'tests' => [
+                    [
+                        'Kasper',
+                        'Kasp',
+                    ],
+                ],
+                'cleared' => [
+                    ''
+                ]
             ],
             'input_4 eval=alpha' => [
-                [
-                    'Kasper = TYPO3',
-                    'KasperTYPO',
-                ],
+                'tests' => [
+                    [
+                        'Kasper = TYPO3',
+                        'KasperTYPO',
+                    ],
+                    [
+                        'Non-latin characters: ŠĐŽĆČ',
+                        'Nonlatincharacters',
+                    ],
+                ],
+                'cleared' => [
+                    ''
+                ]
             ],
             'input_5 eval=alphanum' => [
-                [
-                    'Kasper = TYPO3',
-                    'KasperTYPO3',
-                ],
+                'tests' => [
+                    [
+                        'Kasper = TYPO3',
+                        'KasperTYPO3',
+                    ],
+                ],
+                'cleared' => [
+                    ''
+                ]
             ],
             'input_6 eval=date' => [
-                [
-                    '29-01-2016',
-                    '29-01-2016',
-                    '1454025600',
-                ],
-                [
-                    '13-13-2016',
-                    '13-01-2017',
-                    '1484265600',
-                ],
-
-                'check valid leap year input' => [
-                    '29-02-2016',
-                    '29-02-2016',
-                    '1456704000',
-                ],
-                'check invalid leap year transformation' => [
-                    '29-02-2015',
-                    '01-03-2015',
-                    '1425168000',
-                ],
+                'tests' => [
+                    [
+                        '29-01-2016',
+                        '29-01-2016',
+                        '1454025600',
+                    ],
+                    [
+                        '13-13-2016',
+                        '13-01-2017',
+                        '1484265600',
+                    ],
+                    [
+                        '29-02-2016',
+                        '29-02-2016',
+                        '1456704000',
+                        false,
+                        'Check valid leap year input'
+                    ],
+                    [
+                        '29-02-2015',
+                        '01-03-2015',
+                        '1425168000',
+                        false,
+                        'Check invalid leap year transformation'
+                    ],
+                ],
+                'cleared' => [
+                    '0'
+                ]
+            ],
+            'input_36 dbType=date eval=date' => [
+                'tests' => [
+                    [
+                        '29-01-2016',
+                        '29-01-2016',
+                        '1454025600',
+                    ],
+                    [
+                        '13-13-2016',
+                        '13-01-2017',
+                        '1484265600',
+                    ],
+                    [
+                        '29-02-2016',
+                        '29-02-2016',
+                        '1456704000',
+                        false,
+                        'Check valid leap year input'
+                    ],
+                    [
+                        '29-02-2015',
+                        '01-03-2015',
+                        '1425168000',
+                        false,
+                        'Check invalid leap year transformation'
+                    ],
+                ],
+                'cleared' => [
+                    '0'
+                ]
+            ],
+            'input_7 eval=datetime' => [
+                'tests' => [
+                    [
+                        '05:23 29-01-2016',
+                        '05:23 29-01-2016',
+                        '1454044980',
+                    ],
+                    [
+                        '05:23 13-13-2016',
+                        '05:23 13-01-2017',
+                        '1484284980',
+                    ],
+                    [
+                        '05:23 29-02-2016',
+                        '05:23 29-02-2016',
+                        '1456723380',
+                        false,
+                        'Check valid leap year input'
+                    ],
+                    [
+                        '05:23 29-02-2015',
+                        '05:23 01-03-2015',
+                        '1425187380',
+                        false,
+                        'Check invalid leap year transformation'
+                    ],
+                ],
+                'cleared' => [
+                    '0'
+                ]
+            ],
+            'input_37 dbType=datetime eval=datetime' => [
+                'tests' => [
+                    [
+                        '05:23 29-01-2016',
+                        '05:23 29-01-2016',
+                        '1454044980',
+                    ],
+                    [
+                        '05:23 13-13-2016',
+                        '05:23 13-01-2017',
+                        '1484284980',
+                    ],
+                    [
+                        '05:23 29-02-2016',
+                        '05:23 29-02-2016',
+                        '1456723380',
+                        false,
+                        'Check valid leap year input'
+                    ],
+                    [
+                        '05:23 29-02-2015',
+                        '05:23 01-03-2015',
+                        '1425187380',
+                        false,
+                        'Check invalid leap year transformation'
+                    ],
+                ],
+                'cleared' => [
+                    '0'
+                ]
             ],
             'input_8 eval=double2' => [
-                [
-                    '12.335',
-                    '12.34',
-                ],
-                [
-                    '12,335',
-                    '12.34',
-                ],
-                [
-                    '1.1',
-                    '1.10',
-                ],
-                [
-                    'TYPO3',
-                    '3.00',
-                ],
-                [
-                    '3TYPO',
-                    '3.00',
-                ],
+                'tests' => [
+                    [
+                        '12.335',
+                        '12.34',
+                        '12.34',
+                    ],
+                    [
+                        '12,335',
+                        '12.34',
+                        '12.34',
+                    ],
+                    [
+                        '1.1',
+                        '1.10',
+                        '1.10',
+                    ],
+                    [
+                        'TYPO3',
+                        '3.00',
+                        '3.00',
+                    ],
+                    [
+                        '3TYPO',
+                        '3.00',
+                        '3.00',
+                    ],
+                ],
+                // @todo: add support for null values to the core
+                'cleared' => [
+                    '0.00',
+                    '0.00',
+                ]
             ],
             'input_9 eval=int' => [
-                [
-                    '12.335',
-                    '12',
-                ],
-                [
-                    '12,9',
-                    '12',
-                ],
-                [
-                    'TYPO3',
+                'tests' => [
+                    [
+                        '12.335',
+                        '12',
+                        '12',
+                    ],
+                    [
+                        '12,9',
+                        '12',
+                        '12',
+                    ],
+                    [
+                        'TYPO3',
+                        '0',
+                        '0',
+                    ],
+                    [
+                        '3TYPO',
+                        '3',
+                        '3',
+                    ],
+                ],
+                // @todo: add support for null values to the core
+                'cleared' => [
                     '0',
-                ],
-                [
-                    '3TYPO',
-                    '3',
-                ],
+                    '0',
+                ]
             ],
             'input_10 eval=is_in, is_in=abc123' => [
-                [
-                    'abcd1234',
-                    'abc123',
-                ],
-                [
-                    'Kasper TYPO3',
-                    'a3',
-                ],
+                'tests' => [
+                    [
+                        'abcd1234',
+                        'abc123',
+                    ],
+                    [
+                        'Kasper TYPO3',
+                        'a3',
+                    ],
+                ],
+                'cleared' => [
+                    '',
+                ]
             ],
             'input_11 eval=lower' => [
-                [
-                    'Kasper TYPO3!',
-                    'kasper typo3!',
-                ],
+                'tests' => [
+                    [
+                        'Kasper TYPO3!',
+                        'kasper typo3!',
+                    ],
+                ],
+                'cleared' => [
+                    '',
+                ]
             ],
             'input_12 eval=md5' => [
-                [
-                    'Kasper TYPO3!',
-                    '748469dd64911af8df8f9a3dcb2c9378',
-                ],
-                'check that whitespace is not trimmed' => [
-                    'Kasper TYPO3! ',
-                    '265e09df9b9b08ab1f946510f510d3ef',
-                ],
+                'tests' => [
+                    [
+                        'Kasper TYPO3!',
+                        '748469dd64911af8df8f9a3dcb2c9378',
+                        '748469dd64911af8df8f9a3dcb2c9378',
+                    ],
+                    [
+                        ' Kasper TYPO3! ',
+                        '792a085606250c47d6ebb8c98804d5b0',
+                        '792a085606250c47d6ebb8c98804d5b0',
+                        false,
+                        'Check that whitespaces are not trimmed.'
+                    ],
+                ],
+                'cleared' => [
+                    // @todo: add support for null values to the core
+                    // cleared value currently keeps the previous value on save
+                    '792a085606250c47d6ebb8c98804d5b0',
+                    '792a085606250c47d6ebb8c98804d5b0'
+                ]
+
             ],
             'input_13 eval=nospace' => [
-                [
-                    ' Kasper TYPO3! ',
-                    'KasperTYPO3!',
-                ],
+                'tests' => [
+                    [
+                        ' Kasper TYPO3! ',
+                        'KasperTYPO3!',
+                    ],
+                ],
+                'cleared' => [
+                    '',
+                ]
             ],
             // @todo define test
             //'input_14 eval=null' => [
             //],
             'input_15 eval=num' => [
-                [
-                    '12.335',
-                    '12335',
-                ],
-                [
-                    '12,9',
-                    '129',
-                ],
-                [
-                    'TYPO3',
-                    '3',
-                ],
-                [
-                    '3TYPO',
-                    '3',
-                ],
+                'tests' => [
+                    [
+                        '12.335',
+                        '12335',
+                    ],
+                    [
+                        '12,9',
+                        '129',
+                    ],
+                    [
+                        'TYPO3',
+                        '3',
+                    ],
+                    [
+                        '3TYPO',
+                        '3',
+                    ],
+                ],
+                'cleared' => [
+                    '',
+                ]
             ],
             'input_16 eval=password' => [
-                [
-                    'Kasper',
-                    '********',
-                    'Kasper',
-                ],
+                'tests' => [
+                    [
+                        'Kasper',
+                        '********',
+                        'Kasper',
+                    ],
+                ],
+                'cleared' => [
+                    '',
+                ]
             ],
             'input_17 eval=time' => [
-                [
-                    '13:30',
-                    '13:30',
-                    '48600',
-                ],
-                [
-                    '123',
-                    '12:03',
-                    '43380',
-                ],
-                [
-                    '12345',
-                    '12:34',
-                    '45240',
-                ],
-                [
-                    '12:04+5',
-                    '12:09',
-                    '43740',
-                ],
-                [
-                    '12:09-3',
-                    '12:06',
-                    '43560',
+                'tests' => [
+                    [
+                        '13:30',
+                        '13:30',
+                        '48600',
+                    ],
+                    [
+                        '123',
+                        '12:03',
+                        '43380',
+                    ],
+                    [
+                        '12345',
+                        '12:34',
+                        '45240',
+                    ],
+                    [
+                        '12:04+5',
+                        '12:09',
+                        '43740',
+                    ],
+                    [
+                        '12:09-3',
+                        '12:06',
+                        '43560',
+                    ]
+                ],
+                'cleared' => [
+                    '0',
+                    '00:00',
                 ]
             ],
             'input_18 eval=timesec' => [
-                [
-                    '13:30:00',
-                    '13:30:00',
-                    '48600',
-                ],
-                [
-                    '12345',
-                    '12:34:05',
-                    '45245',
-                ],
-                [
-                    // @todo is that the expected behavior?
-                    '12:04:04+5',
-                    '12:09:04',
-                    '43744',
-                ],
+                'tests' => [
+                    [
+                        '13:30:00',
+                        '13:30:00',
+                        '48600',
+                    ],
+                    [
+                        '12345',
+                        '12:34:05',
+                        '45245',
+                    ],
+                    [
+                        // @todo is that the expected behavior?
+                        '12:04:04+5',
+                        '12:09:04',
+                        '43744',
+                    ],
+                ],
+                'cleared' => [
+                    '0',
+                    '00:00:00',
+                ]
             ],
             'input_19 eval=trim' => [
-                [
-                    ' Kasper ',
-                    'Kasper',
-                ],
-                [
-                    ' Kasper TYPO3 ',
-                    'Kasper TYPO3',
-                ],
+                'tests' => [
+                    [
+                        ' Kasper ',
+                        'Kasper',
+                    ],
+                    [
+                        ' Kasper TYPO3 ',
+                        'Kasper TYPO3',
+                    ],
+                ],
+                'cleared' => [
+                    '',
+                ]
             ],
             // @todo Check why this test is currently broken
             //'input_20 eval with user function' => [
@@ -264,54 +474,84 @@ class ElementsBasicCest
             //    ]
             //],
             'input_23 eval=upper' => [
-                [
-                    'Kasper TYPO3!',
-                    'KASPER TYPO3!',
-                ],
+                'tests' => [
+                    [
+                        'Kasper TYPO3!',
+                        'KASPER TYPO3!',
+                    ],
+                ],
+                'cleared' => [
+                    '',
+                ]
             ],
             'input_24 eval=year' => [
-                [
-                    '2016',
-                    '2016',
-                ],
-                [
-                    '12',
-                    '2012',
-                ],
-                'Invalid character is converted to current year' => [
-                    'Kasper',
-                    date('Y'),
-                ],
+                'tests' => [
+
+                    [
+                        '2016',
+                        '2016',
+                        '2016',
+                    ],
+                    [
+                        '12',
+                        '2012',
+                        '2012',
+                    ],
+                    [
+                        'Kasper',
+                        date('Y'),
+                        date('Y'),
+                        false,
+                        'Invalid character is converted to current year'
+                    ],
+                ],
+                'cleared' => [
+                    '0',
+                    '0',
+                ]
             ],
             'input_25 eval=int, default=0, range lower=-2, range upper=2' => [
-                [
-                    'Kasper TYPO3',
+                'tests' => [
+                    [
+                        'Kasper TYPO3',
+                        '0',
+                        '0',
+                    ],
+                    [
+                        '2',
+                        '2',
+                        '2'
+                    ],
+                    [
+                        '-1',
+                        '-1',
+                        '-1',
+                    ],
+                    [
+                        '-3',
+                        '-3',
+                        '-3',
+                        true,
+                        'Expecting a modal with error on trying to save.'
+                    ],
+                    [
+                        '3',
+                        '-3',
+                        '-3',
+                        true,
+                        'Expecting a modal with error on trying to save.'
+                    ],
+                ],
+                'cleared' => [
                     '0',
-                ],
-                [
-                    '2',
-                    '2',
-                ],
-                [
-                    '-1',
-                    '-1',
-                ],
-                [
-                    '-3',
-                    '-3',
-                    // @todo Check for validation error
-                ],
-                [
-                    '3',
-                    '3',
-                    // @todo Check for validation error
-                ],
+                    '0'
+                ]
             ],
         ];
 
-        foreach ($fieldTests as $fieldKey => $testData) {
-            $formhandler->fillSeeDeleteInputField(
-                $formhandler->getContextForFormhandlerField($fieldKey),
+        foreach ($fieldTests as $fieldLabel => $testData) {
+            $formhandler->fillSeeSaveAndClearInputField(
+                $fieldLabel,
                 $testData
             );
         }
index 9ffc269..7731726 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Core\Tests\Acceptance\Support\Helper;
  */
 
 use Facebook\WebDriver\Remote\RemoteWebElement;
+use Facebook\WebDriver\WebDriverKeys;
 
 /**
  * Helper to interact with formhandler fields
@@ -44,22 +45,21 @@ class Formhandler
      * @param string $fieldName
      * @return RemoteWebElement
      */
-    public function getContextForFormhandlerField(string $fieldName)
+    protected function getContextForFormhandlerField(string $fieldName)
     {
         $I = $this->tester;
         $I->comment('Get context for field "' . $fieldName . '"');
 
         return $I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) use ($fieldName) {
-            // TODO FIX THAT! MUST JUST BE ONE XPATH (and maybe it should work)
-            return $webdriver->findElement(\WebDriverBy::xpath('//label[contains(text(),"' . $fieldName . '")]'))->findElement(
-                \WebDriverBy::xpath('ancestor::fieldset[@class="form-section"][1]')
+            return $webdriver->findElement(
+                \WebDriverBy::xpath('(//label[contains(text(),"' . $fieldName . '")])[1]/ancestor::fieldset[@class="form-section"][1]')
             );
         });
     }
 
     /**
-     * @param RemoteWebElement $fieldContext
-     * @param array $testValues An array of arrays that contains the values to validate.
+     * @param string $fieldLabel
+     * @param array $testData An array of arrays that contains the data to validate.
      *  * First value is the input value
      *  * second value is the value that is expected after the validation
      *  * optional third value is the "internal" value like required for date fields (value is internally
@@ -67,33 +67,97 @@ class Formhandler
      *  Example for field with alpha validation: [['foo', 'foo'], ['bar1'], ['bar']]
      *  Example for field with date validation: [['29-01-2016', '29-01-2016', '1454025600']]
      */
-    public function fillSeeDeleteInputField(RemoteWebElement $fieldContext, array $testValues)
+    public function fillSeeSaveAndClearInputField($fieldLabel, array $testData)
     {
+        $fieldContext = $this->getContextForFormhandlerField($fieldLabel);
         $I = $this->tester;
         $I->wantTo('Fill field, check the fieldvalue after evaluation and delete the value.');
 
-        $inputField = $fieldContext->findElement(\WebDriverBy::xpath('.//*/input[@data-formengine-input-name]'));
-        $internalInputField = $fieldContext->findElement(\WebDriverBy::xpath('.//*/input[@name="' . $inputField->getAttribute('data-formengine-input-name') . '"]'));
+        $visibleFieldXpath = './/*/input[@data-formengine-input-name]';
+        $clearButtonXpath = '(//label[contains(text(),"' . $fieldLabel . '")])[1]/parent::*//*/button[@class="close"]';
+        $initializedInputFieldXpath = '(//label[contains(text(),"' . $fieldLabel . '")])[1]/parent::*//*/input[@data-formengine-input-name][@data-formengine-input-initialized]';
+        $I->waitForElement($initializedInputFieldXpath, 30);
+        $inputField = $fieldContext->findElement(\WebDriverBy::xpath($visibleFieldXpath));
+        $internalInputFieldXpath = '(//label[contains(text(),"' . $fieldLabel . '")])[1]/parent::*//*/input[@name="' . $inputField->getAttribute('data-formengine-input-name') . '"]';
 
-        foreach ($testValues as $comment => $testValue) {
-            if (!empty($comment)) {
-                $I->comment($comment);
+        $I->waitForElement($internalInputFieldXpath, 30);
+        $I->waitForElement($clearButtonXpath, 30);
+
+        // the internal field name will not change during this function execution
+        $internalFieldXpath = './/*/input[@name="' . $inputField->getAttribute('data-formengine-input-name') . '"]';
+        $internalInputField = $fieldContext->findElement(\WebDriverBy::xpath($internalFieldXpath));
+
+        foreach ($testData['tests'] as $testValue) {
+            if (isset($testValue[4])) {
+                $I->comment($testValue[4]);
             }
             $I->comment('Fill the field and switch focus to trigger validation.');
             $I->fillField($inputField, $testValue[0]);
             // change the focus to trigger validation
-            $fieldContext->sendKeys("\n");
+            $inputField->sendKeys(WebDriverKeys::TAB);
+            // click on the div so that any opened popup (potentially from the field below) is closed
+            $fieldContext->click();
 
             $I->comment('Test value of "visible" field');
             $I->canSeeInField($inputField, $testValue[1]);
             $I->comment('Test value of the internal field');
             $I->canSeeInField($internalInputField, (isset($testValue[2]) ? $testValue[2] : $testValue[1]));
+
+            // save the change
+            $saveButtonLink = '//*/button[@name="_savedok"][1]';
+            $I->waitForElement($saveButtonLink, 30);
+            if (isset($testValue[3]) && $testValue[3]) {
+                $I->click($saveButtonLink);
+                $I->switchToWindow();
+                $notificationCloseXpath = '//*[@class="modal-title"][contains(text(),"Alert")]/parent::*/button[@class="close"]';
+                $I->waitForElement($notificationCloseXpath, 30);
+                $I->click($notificationCloseXpath);
+                return;
+            } else {
+                $I->click($saveButtonLink);
+            }
+
+            // wait for the save to be completed
+            $I->waitForElement('//*/button[@name="_savedok"][not(@disabled)][1]', 30);
+            $I->waitForElement($initializedInputFieldXpath, 30);
+            $I->waitForElement($internalInputFieldXpath, 30);
+            $I->waitForElement($clearButtonXpath, 30);
+
+            // find the input fields again
+            $fieldContext = $this->getContextForFormhandlerField($fieldLabel);
+            $inputField = $fieldContext->findElement(\WebDriverBy::xpath($visibleFieldXpath));
+            $internalInputField = $fieldContext->findElement(\WebDriverBy::xpath($internalFieldXpath));
+
+            // validate that the save was successfull
+            $I->comment('Test value of "visible" field after the save');
+            $I->canSeeInField($inputField, $testValue[1]);
+            $I->comment('Test value of the internal field after the save');
+            $I->canSeeInField($internalInputField, isset($testValue[2]) ? $testValue[2] : $testValue[1]);
         }
 
-        $inputField->findElement(\WebDriverBy::xpath('parent::*/button[@class="close"]'))->click();
-        // change the context from the field
-        $fieldContext->sendKeys("\n");
+        // clear the field
+        $I->waitForElement($clearButtonXpath, 30);
+        $I->click($clearButtonXpath);
         $I->canSeeInField($inputField, '');
-        $I->canSeeInField($internalInputField, '');
+
+        // save the change again
+        $saveButtonLink = '//*/button[@name="_savedok"][1]';
+        $I->waitForElement($saveButtonLink, 30);
+        $I->click($saveButtonLink);
+
+        // wait for the save to be completed
+        $I->waitForElement('//*/button[@name="_savedok"][not(@disabled)][1]', 30);
+        $I->waitForElement($initializedInputFieldXpath, 30);
+        $I->waitForElement($internalInputFieldXpath, 30);
+        $I->waitForElement($clearButtonXpath, 30);
+
+        // find the input fields again
+        $fieldContext = $this->getContextForFormhandlerField($fieldLabel);
+        $inputField = $fieldContext->findElement(\WebDriverBy::xpath($visibleFieldXpath));
+        $internalInputField = $fieldContext->findElement(\WebDriverBy::xpath($internalFieldXpath));
+
+        // validate that the save was successfull
+        $I->canSeeInField($inputField, isset($testData['cleared'][1]) ? $testData['cleared'][1] : '');
+        $I->canSeeInField($internalInputField, isset($testData['cleared'][0]) ? $testData['cleared'][0] : '');
     }
 }