File size: 1,030 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
import { Page, Response } from 'playwright';
import { getCalypsoURL } from '../../data-helper';
const selectors = {
// General
addNewPageButton: 'a.page-title-action, span.split-page-title-action>a',
};
/**
* Represents the Pages page
*/
export class PagesPage {
private page: Page;
/**
* Creates an instance of the page.
*
* @param {Page} page Object representing the base page.
*/
constructor( page: Page ) {
this.page = page;
}
/**
* Opens the Pages page.
*
* Example {@link https://wordpress.com/pages}
*/
async visit(): Promise< Response | null > {
const response = await this.page.goto( getCalypsoURL( 'pages' ) );
return response;
}
/**
* Start a new page using the 'Add new page' button.
*/
async addNewPage(): Promise< void > {
const locator = this.page.locator( selectors.addNewPageButton );
await locator.click( { timeout: 20 * 1000 } );
await this.page.waitForURL( /post-new.php\?post_type=page/, {
timeout: 20 * 1000,
waitUntil: 'domcontentloaded',
} );
}
}
|