‪TYPO3CMS  ‪main
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\Remote\RemoteWebDriver;
21 use Facebook\WebDriver\WebDriverBy;
22 use Facebook\WebDriver\WebDriverKeys;
24 
25 final class ‪PageTree extends ‪AbstractTree
26 {
27  public static ‪$treeSelector = '#typo3-pagetree-treeContainer';
28 
30 
35  {
36  $this->tester = $I;
37  $this->mouse = ‪$mouse;
38  }
39 
43  public function ‪dragAndDropNewPage(string $pageName, string $dragNode, string $nodeEditInput): void
44  {
45  $target = $this->‪getPageXPathByPageName($pageName);
46  $pageTitle = sprintf('Dummy 1-%s-new', $pageName);
47 
48  $this->mouse->dragAndDrop($dragNode, $target);
49 
50  $this->tester->seeElement($nodeEditInput);
51 
52  // Change the new page title.
53  // We can't use $I->fillField() here since this sends a clear() to the element
54  // which drops the node creation in the tree. So we do it manually with selenium.
55  $element = $this->tester->executeInSelenium(static function (RemoteWebDriver $webdriver) use ($nodeEditInput) {
56  return $webdriver->findElement(WebDriverBy::cssSelector($nodeEditInput));
57  });
58  $element->sendKeys($pageTitle);
59 
60  $this->tester->pressKey($nodeEditInput, WebDriverKeys::ENTER);
61  $this->tester->waitForElementNotVisible($nodeEditInput);
62  $this->tester->waitForText($pageTitle);
63  }
64 
68  public function ‪getPageXPathByPageName(string $pageName): string
69  {
70  return '//*[@class="node-name" and text()=\'' . $pageName . '\']/..';
71  }
72 }
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree\$treeSelector
‪static $treeSelector
Definition: PageTree.php:27
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\Mouse
Definition: Mouse.php:35
‪TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester
Definition: ApplicationTester.php:28
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree\getPageXPathByPageName
‪getPageXPathByPageName(string $pageName)
Definition: PageTree.php:68
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree\__construct
‪__construct(ApplicationTester $I, Mouse $mouse)
Definition: PageTree.php:34
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree\dragAndDropNewPage
‪dragAndDropNewPage(string $pageName, string $dragNode, string $nodeEditInput)
Definition: PageTree.php:43
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\AbstractTree
Definition: AbstractTree.php:26
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper
Definition: AbstractTree.php:18
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree
Definition: PageTree.php:26
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree\$mouse
‪Mouse $mouse
Definition: PageTree.php:29