Page


#Native pages

PrestaFlow includes a series of so-called native pages.

These are the pages found in your PrestaShop store, such as product pages, categories, CMS, contact, etc.

#Import page

Copied!
1$this->importPage('FrontOffice\Category');

In order to use the imported pages, it is necessary to extract them!

Copied!
1extract($this->pages);

Once imported, you will be able to use a page in your steps via a use within the step closure.

The variable name is defined as follows:

  • FrontOffice\Category => $frontOfficeCategoryPage
  • FrontOffice\Product => $frontOfficeProductPage

#Custom page

#Create

Copied!
1namespace Shop\Tests\Pages\v9\Modules\Custom;
2 
3use PrestaFlow\Library\Pages\v9\FrontOffice\Page as BasePage;
4 
5class Page extends BasePage
6{
7 public string $url = 'guest-tracking';
8 public string $pageTitle = 'Guest Order Tracking';
9 
10 public function defineMessages()
11 {
12 return [
13 'addedToCart' => $this->translate('Product successfully added to your shopping cart'),
14 ];
15 }
16 
17 public function getPrice()
18 {
19 return $this->getTextContent($this->getSelector('currentProductPrice'));
20 }
21 
22 public function addToCart(int $quantity = 1)
23 {
24 $this->setValue($this->getSelector('quantityWantedInput'), $quantity);
25 
26 $this->click($this->getSelector('addToCartButton'));
27 
28 return ltrim($this->getTextContent($this->getSelector('modalTitle')));
29 }
30}

#Import page

To import a custom page, you use the same call as to import a regular page, adding the domain it applies to.

Copied!
1$this->importPage('Modules\Custom', domain: 'Shop\Tests');

After the extraction of the page, you can use it as this :

Copied!
1$testSuite
2->it('should go to page', function () use ($modulesCustomPage) {
3 $modulesCustomPage->goToPage($modulesCustomPage);
4 
5 Expect::that($modulesCustomPage->getPageTitle())->contains($modulesCustomPage->pageTitle());
6})
7 
8;