‪TYPO3CMS  10.4
PageTree.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Facebook\WebDriver\WebDriverKeys;
22 use TYPO3\TestingFramework\Core\Acceptance\Helper\AbstractPageTree;
23 
27 class ‪PageTree extends AbstractPageTree
28 {
32  private ‪$mouse;
33 
40  {
41  $this->tester = $I;
42  $this->mouse = ‪$mouse;
43  }
44 
48  public function ‪dragAndDropNewPage(string $pageName, string $dragNode, string $nodeEditInput): void
49  {
50  $target = $this->‪getPageXPathByPageName($pageName);
51  $pageTitle = sprintf('Dummy 1-%s-new', $pageName);
52 
53  $this->mouse->dragAndDrop($dragNode, $target);
54 
55  $this->tester->seeElement($nodeEditInput);
56 
57  // Change the new page title.
58  // We can't use $I->fillField() here since this sends a clear() to the element
59  // which drops the node creation in the tree. So we do it manually with selenium.
60  $element = $this->tester->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) use ($nodeEditInput) {
61  return $webdriver->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector($nodeEditInput));
62  });
63  $element->sendKeys($pageTitle);
64 
65  $this->tester->pressKey($nodeEditInput, WebDriverKeys::ENTER);
66  $this->tester->waitForElementNotVisible($nodeEditInput);
67  $this->tester->see($pageTitle);
68  }
69 
76  public function ‪getPageXPathByPageName(string $pageName): string
77  {
78  return '//*[text()=\'' . $pageName . '\']';
79  }
80 }
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\Mouse
Definition: Mouse.php:35
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree\__construct
‪__construct(BackendTester $I, Mouse $mouse)
Definition: PageTree.php:38
‪TYPO3\CMS\Core\Tests\Acceptance\Support\BackendTester
Definition: BackendTester.php:27
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree\dragAndDropNewPage
‪dragAndDropNewPage(string $pageName, string $dragNode, string $nodeEditInput)
Definition: PageTree.php:47
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper
Definition: Config.php:18
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree
Definition: PageTree.php:28
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree\$mouse
‪Mouse $mouse
Definition: PageTree.php:31
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree\getPageXPathByPageName
‪string getPageXPathByPageName(string $pageName)
Definition: PageTree.php:75