[TASK] Tests: Use existing session
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Acceptance / Backend / Page / AddPageInPageModuleCest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Page;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Admin;
18
19 /**
20 * This testcase is used to check if a page can be added with the page module.
21 * It also tests to remove the new page with the page tree context menu.
22 */
23 class AddPageInPageModuleCest
24 {
25 public function _before(Admin $I)
26 {
27 $I->useExistingSession();
28 // Ensure main content frame is fully loaded, otherwise there are load-race-conditions
29 $I->switchToIFrame('content');
30 $I->waitForText('Web>Page module');
31 $I->switchToIFrame();
32 }
33
34 /**
35 * @param Admin $I
36 */
37 public function tryToTest(Admin $I)
38 {
39 // Select page module
40 $I->wantToTest('Add a page with page module');
41 $I->click('Page');
42
43 // New page from root page
44 $typo3NavigationContainer = '#typo3-navigationContainer';
45 $I->waitForElement($typo3NavigationContainer);
46 $rootNode = 'a.x-tree-node-anchor > span';
47 $rootNodeIcon = '#extdd-1 > span.t3js-icon.icon.icon-size-small.icon-state-default.icon-apps-pagetree-root';
48 $contextMenuNew = '#typo3-pagetree-contextmenu > ul > li.x-menu-list-item:nth-of-type(2) > a > span.x-menu-item-text';
49 $I->waitForElement($rootNode);
50 $I->click($rootNodeIcon);
51 $I->waitForElement($contextMenuNew);
52 $I->click($contextMenuNew);
53
54 // Switch to content frame
55 $I->switchToIFrame('content');
56
57 // New page select position wizard
58 $I->click('i[title="Insert the new page here"]');
59
60 // FormEngine new page record
61 $saveButton = 'body > div > div.module-docheader.t3js-module-docheader > div.module-docheader-bar.module-docheader-bar-buttons.t3js-module-docheader-bar.t3js-module-docheader-bar-buttons > div.module-docheader-bar-column-left > div > div > button:nth-child(1)';
62 $I->waitForElement($saveButton);
63
64 // Check empty
65 $I->amGoingTo('check empty error');
66 $I->click($saveButton);
67 $I->wait(2);
68 $editControllerDiv = '#EditDocumentController > div';
69 $generalTab = $editControllerDiv . ' > div:nth-child(1) > ul > li';
70 $classString = $I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) use (
71 $generalTab
72 ) {
73 return $webdriver->findElement(\WebDriverBy::cssSelector($generalTab))->getAttribute('class');
74 });
75 $I->assertContains('has-validation-error', $classString);
76
77 // Add page
78 $pageTitle = $editControllerDiv . ' > div:nth-child(1) > div > div.tab-pane:nth-child(1) > fieldset:nth-child(2) > div > div:nth-child(1) > div > div.form-control-wrap > div > input';
79 $I->fillField($pageTitle, 'Testpage');
80 $I->click($saveButton);
81 $I->waitForElement($pageTitle);
82 $I->assertEquals('Testpage', $I->grabValueFrom($pageTitle), 'Value in input field.');
83 $I->switchToIFrame();
84
85 // Check tree
86 $I->waitForElement($typo3NavigationContainer);
87 $pageInTree = '#typo3-pagetree-tree > div > div > ul > div > li > ul > li > div > a > span';
88 $I->assertEquals('Testpage', $I->grabTextFrom($pageInTree), 'Value in tree.');
89
90 // And delete page from tree
91 $pageInTreeIcon = '#typo3-pagetree-tree > div > div > ul > div > li > ul > li > div > span.t3js-icon.icon.icon-size-small.icon-state-default.icon-apps-pagetree-page-default';
92 $pageActions = '#typo3-pagetree-contextmenu > ul > li:nth-child(8) > a > span.x-menu-item-text';
93 $delete = '#typo3-pagetree-contextmenu-sub1 > ul > li:nth-child(6) > a > span.x-menu-item-text';
94 $I->click($pageInTreeIcon);
95 $I->waitForElement('#typo3-pagetree-contextmenu');
96 $I->waitForElement($pageActions);
97 $I->moveMouseOver($pageActions);
98 $I->waitForElement('#typo3-pagetree-contextmenu-sub1');
99 $I->click($delete);
100 $yesButtonPopup = '#main > div.x-window.x-window-plain.x-window-dlg > div.x-window-bwrap > div.x-window-bl > div > div > div > div.x-panel-fbar.x-small-editor.x-toolbar-layout-ct > table > tbody > tr > td.x-toolbar-left > table > tbody > tr > td:nth-child(2) > table > tbody > tr:nth-child(2) > td.x-btn-mc > em > button';
101 $I->waitForElement($yesButtonPopup);
102 $I->click($yesButtonPopup);
103 $I->wait(2);
104 $I->cantSee('Testpage');
105 }
106 }