[BUGFIX] Streamline iframe namings for new backend
[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 * Page and page tree related tests.
21 */
22 class AddPageInPageModuleCest
23 {
24 public function _before(Admin $I)
25 {
26 $I->useExistingSession();
27 // Ensure main content frame is fully loaded, otherwise there are load-race-conditions
28 $I->switchToIFrame('list_frame');
29 $I->waitForText('Web Content Management System');
30 $I->switchToIFrame();
31 }
32
33 /**
34 * This test case is used to check if a page can be added with the page module.
35 * It also tests to remove the new page with the page tree context menu.
36 *
37 * @param Admin $I
38 */
39 public function addAndDeletePage(Admin $I)
40 {
41 // Select page module
42 $I->wantToTest('Add a page with page module');
43 $I->click('Page');
44
45 // New page from root page
46 $typo3NavigationContainer = '.scaffold-content-navigation-component';
47 $I->waitForElement($typo3NavigationContainer);
48 $rootNode = 'a.x-tree-node-anchor > span';
49 $rootNodeIcon = '#extdd-1 > span.t3js-icon.icon.icon-size-small.icon-state-default.icon-apps-pagetree-root';
50 $contextMenuNew = '#typo3-pagetree-contextmenu > ul > li.x-menu-list-item:nth-of-type(2) > a > span.x-menu-item-text';
51 $I->waitForElement($rootNode);
52 $I->click($rootNodeIcon);
53 $I->waitForElement($contextMenuNew);
54 $I->click($contextMenuNew);
55
56 // Switch to content frame
57 $I->switchToIFrame('list_frame');
58
59 // New page select position wizard
60 $I->click('i[title="Insert the new page here"]');
61
62 // FormEngine new page record
63 $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)';
64 $I->waitForElement($saveButton);
65
66 // Check empty
67 $I->amGoingTo('check empty error');
68 $I->click($saveButton);
69 $I->wait(2);
70 $editControllerDiv = '#EditDocumentController > div';
71 $generalTab = $editControllerDiv . ' > div:nth-child(1) > ul > li';
72 $classString = $I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) use (
73 $generalTab
74 ) {
75 return $webdriver->findElement(\WebDriverBy::cssSelector($generalTab))->getAttribute('class');
76 });
77 $I->assertContains('has-validation-error', $classString);
78
79 // Add page
80 $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';
81 $I->fillField($pageTitle, 'Testpage');
82 $I->click($saveButton);
83 $I->waitForElement($pageTitle);
84 $I->assertEquals('Testpage', $I->grabValueFrom($pageTitle), 'Value in input field.');
85 $I->switchToIFrame();
86
87 // Check tree
88 $I->waitForElement($typo3NavigationContainer);
89 $pageInTree = '#typo3-pagetree-tree > div > div > ul > div > li > ul > li > div > a > span';
90 $I->assertEquals('Testpage', $I->grabTextFrom($pageInTree), 'Value in tree.');
91
92 // And delete page from tree
93 $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';
94 $pageActions = '#typo3-pagetree-contextmenu > ul > li:nth-child(8) > a > span.x-menu-item-text';
95 $delete = '#typo3-pagetree-contextmenu-sub1 > ul > li:nth-child(6) > a > span.x-menu-item-text';
96 $I->click($pageInTreeIcon);
97 $I->waitForElement('#typo3-pagetree-contextmenu');
98 $I->waitForElement($pageActions);
99 $I->moveMouseOver($pageActions);
100 $I->waitForElement('#typo3-pagetree-contextmenu-sub1');
101 $I->click($delete);
102 $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';
103 $I->waitForElement($yesButtonPopup);
104 $I->click($yesButtonPopup);
105 $I->wait(2);
106 $I->cantSee('Testpage');
107 }
108 }