‪TYPO3CMS  11.5
SitemapXmlCest.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 Codeception\Example;
21 use Facebook\WebDriver\Remote\RemoteWebDriver;
22 use Facebook\WebDriver\Remote\RemoteWebElement;
23 use Facebook\WebDriver\WebDriverBy;
26 
28 {
29  protected string ‪$sidebar = '.sidebar.list-group';
30 
34  public function ‪_before(‪ApplicationTester $I, ‪PageTree $pageTree)
35  {
36  $I->useExistingSession('admin');
37  $I->click('Page');
38  $I->waitForElement('#typo3-pagetree-tree .nodes .node', 5);
39  $pageTree->‪openPath(['styleguide frontend demo']);
40  $I->switchToContentFrame();
41  $I->waitForElementVisible('.t3js-module-docheader-bar a[title="View webpage"]');
42  $I->wait(2);
43  $I->click('.t3js-module-docheader-bar a[title="View webpage"]');
44  $I->executeInSelenium(function (RemoteWebDriver $webdriver) {
45  $handles = $webdriver->getWindowHandles();
46  $lastWindow = end($handles);
47  $webdriver->switchTo()->window($lastWindow);
48  });
49 
50  // Get current url
51  $url = $this->‪getCurrentURL($I);
52  // Add Sitemap parameter to URL
53  $I->amOnUrl($url . '?type=1533906435');
54  }
55 
61  private function ‪getCurrentURL(‪ApplicationTester $I, int $attempt = 1): string
62  {
63  $url = $I->executeInSelenium(function (RemoteWebDriver $webdriver) {
64  return $webdriver->getCurrentURL();
65  });
66 
67  if ($attempt > 4) {
68  return $url ?? '';
69  }
70 
71  if (!$url || str_contains($url, 'about:blank')) {
72  $I->wait(0.5);
73  $url = $this->‪getCurrentURL($I, $attempt + 1);
74  }
75 
76  return $url;
77  }
78 
83  public function ‪seeSitemapXml(‪ApplicationTester $I, Example $testData): void
84  {
85  $I->see('TYPO3 XML Sitemap');
86  $I->see('sitemap=pages');
87  $I->see('type=1533906435');
88 
89  $I->amGoingTo('See sitemap pages details');
90  $I->click('a');
91 
92  $I->see($testData['slug']);
93  $priority = $this->‪getTableColumn($I, $testData['slug'])->getText();
94  $I->assertIsNumeric($priority);
95  }
96 
100  protected function ‪sitemapDataProvider(): array
101  {
102  return [
103  ['slug' => '/bullets'],
104  ['slug' => '/div'],
105  ['slug' => '/header'],
106  ['slug' => '/text'],
107  ['slug' => '/textpic'],
108  ['slug' => '/textmedia'],
109  ['slug' => '/image'],
110  ['slug' => '/html'],
111  ['slug' => '/table'],
112  ['slug' => '/felogin-login'],
113  ['slug' => '/form-formframework'],
114  ['slug' => '/list'],
115  ['slug' => '/shortcut'],
116  ['slug' => '/uploads'],
117  ['slug' => '/menu-categorized-pages'],
118  ['slug' => '/menu-categorized-content'],
119  ['slug' => '/menu-pages'],
120  ['slug' => '/menu-subpages'],
121  ['slug' => '/menu-sitemap'],
122  ['slug' => '/menu-section'],
123  ['slug' => '/menu-abstract'],
124  ['slug' => '/menu-recently-updated'],
125  ['slug' => '/menu-related-pages'],
126  ['slug' => '/menu-section-pages'],
127  ['slug' => '/menu-sitemap-pages'],
128  ];
129  }
130 
139  protected function ‪getTableColumn(‪ApplicationTester $I, string $slug, int $sibling = 3): RemoteWebElement
140  {
141  $I->comment('Get context for table row "' . $slug . '"');
142  return $I->executeInSelenium(
143  function (RemoteWebDriver $webDriver) use ($slug, $sibling) {
144  return $webDriver->findElement(
145  WebDriverBy::xpath(
146  '//a[contains(text(),"' . $slug . '")]/ancestor::td/following-sibling::td[' . $sibling . ']'
147  )
148  );
149  }
150  );
151  }
152 }
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend
Definition: ContentElementsCest.php:18
‪TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester
Definition: ApplicationTester.php:27
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree\openPath
‪openPath(array $path)
Definition: PageTree.php:76
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend\SitemapXmlCest
Definition: SitemapXmlCest.php:28
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend\SitemapXmlCest\sitemapDataProvider
‪array sitemapDataProvider()
Definition: SitemapXmlCest.php:100
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend\SitemapXmlCest\seeSitemapXml
‪seeSitemapXml(ApplicationTester $I, Example $testData)
Definition: SitemapXmlCest.php:83
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend\SitemapXmlCest\getTableColumn
‪RemoteWebElement getTableColumn(ApplicationTester $I, string $slug, int $sibling=3)
Definition: SitemapXmlCest.php:139
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend\SitemapXmlCest\_before
‪_before(ApplicationTester $I, PageTree $pageTree)
Definition: SitemapXmlCest.php:34
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend\SitemapXmlCest\$sidebar
‪string $sidebar
Definition: SitemapXmlCest.php:29
‪TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\PageTree
Definition: PageTree.php:31
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Frontend\SitemapXmlCest\getCurrentURL
‪string getCurrentURL(ApplicationTester $I, int $attempt=1)
Definition: SitemapXmlCest.php:61