Commit a9a957e9 authored by Jochen Roth's avatar Jochen Roth Committed by Christian Kuhn
Browse files

[BUGFIX] Stabilize formengine input tests

In some cases the tabs are not in viewport
so the elements can't be click by any
acceptance test.

This has been fixed by scrolling the tabs
into the viewport to make sure the ac test
is able to click the item.

Resolves: #96182
Releases: master, 11.5
Change-Id: I69624b7f158fd2d13d16a05e07ec960beac10be6
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72416

Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent e028095c
......@@ -18,8 +18,6 @@ declare(strict_types=1);
namespace TYPO3\CMS\Core\Tests\Acceptance\Application\FormEngine;
use Codeception\Example;
use Facebook\WebDriver\Exception\ElementClickInterceptedException;
use Facebook\WebDriver\Exception\UnknownErrorException;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Facebook\WebDriver\Remote\RemoteWebElement;
use Facebook\WebDriver\WebDriverKeys;
......@@ -128,36 +126,4 @@ abstract class AbstractElementsBasicCest
}
);
}
/**
* @param ApplicationTester $I
* @param string $tabTitle the tab you want to click. If necessary, several attempts are made
* @param string $referenceField one field that is available to receive a click. Will be used to scroll up from there.
*/
protected function ensureTopOfFrameIsUsedAndClickTab(ApplicationTester $I, string $tabTitle, string $referenceField): void
{
try {
$I->click($tabTitle);
} catch (UnknownErrorException | ElementClickInterceptedException $exception) {
// this is fired if the element can't be clicked, because for example another element overlays it.
$this->scrollToTopOfFrame($I, $tabTitle, $referenceField);
}
}
protected function scrollToTopOfFrame(ApplicationTester $I, string $tabTitle, string $referenceField): void
{
$formSection = $this->getFormSectionByFieldLabel($I, $referenceField);
$field = $this->getInputField($formSection);
$maxPageUp = 10;
do {
$doItAgain = false;
$maxPageUp--;
try {
$field->sendKeys(WebDriverKeys::PAGE_UP);
$I->click($tabTitle);
} catch (UnknownErrorException | ElementClickInterceptedException $exception) {
$doItAgain = true;
}
} while ($doItAgain === true && $maxPageUp > 0);
}
}
......@@ -50,7 +50,7 @@ class ElementsBasicInputDateCest extends AbstractElementsBasicCest
$I->waitForText('Edit Form', 3, 'h1');
// scroll up all the way to get a clean shot to the tab panel
$this->ensureTopOfFrameIsUsedAndClickTab($I, 'inputDateTime', 'input_23');
$I->executeJS('document.querySelector(".t3js-tabs").scrollIntoView({block: "end"});');
$I->click('inputDateTime');
$I->waitForText('inputDateTime', 3);
......
......@@ -48,7 +48,9 @@ class ElementsBasicInputEvalCest extends AbstractElementsBasicCest
$I->waitForText('Edit Form', 3, 'h1');
// scroll up all the way to get a clean shot to the tab panel
$this->ensureTopOfFrameIsUsedAndClickTab($I, 'input', 'input_23');
$I->executeJS('document.querySelector(".t3js-tabs").scrollIntoView({block: "end"});');
$I->click('input');
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment