cddf85c72aa44af95c3f4502fdfa6106f8bed713
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Acceptance / Support / Helper / ModalDialog.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Acceptance\Support\Helper;
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 AcceptanceTester;
18
19 /**
20 * Helper to interact with modal dialogs that appear for example when
21 * you delete a record or have to confirm something.
22 *
23 * --------------------------------
24 * | Would you like to continue? |
25 * | |
26 * | [no] [maybe] [yeah] |
27 * --------------------------------
28 */
29 class ModalDialog
30 {
31 /**
32 * Selector for a visible modal window
33 *
34 * @var string
35 */
36 public static $openedModalSelector = '.t3-modal.in';
37
38 /**
39 * Selector for the container in the modal where the buttons are located
40 *
41 * @var string
42 */
43 public static $openedModalButtonContainerSelector = '.t3-modal.in .modal-footer';
44
45 /**
46 * @var AcceptanceTester
47 */
48 protected $tester;
49
50 /**
51 * @param AcceptanceTester $I
52 */
53 public function __construct(\AcceptanceTester $I)
54 {
55 $this->tester = $I;
56 }
57
58 /**
59 * Perform a click on a link or a button, given by a locator.
60 *
61 * @param string $buttonLinkLocator the button title
62 * @see \Codeception\Module\WebDriver::click()
63 */
64 public function clickButtonInDialog(string $buttonLinkLocator)
65 {
66 $I = $this->tester;
67 $this->canSeeDialog();
68 $I->click($buttonLinkLocator, self::$openedModalButtonContainerSelector);
69 }
70
71 /**
72 * Check if modal dialog is visible in top frame
73 */
74 public function canSeeDialog()
75 {
76 $I = $this->tester;
77 $I->switchToIFrame();
78 $I->waitForElement(self::$openedModalSelector);
79 }
80 }