diff --git a/tests/e2e/specs/edit-posts.test.js b/tests/e2e/specs/edit-posts.test.js index 51d8824bb5..0dce05163f 100644 --- a/tests/e2e/specs/edit-posts.test.js +++ b/tests/e2e/specs/edit-posts.test.js @@ -27,15 +27,17 @@ describe( 'Edit Posts', () => { await page.waitForSelector( '#the-list .type-post' ); - // Expect there to be one row in the post list. - const posts = await page.$$( '#the-list .type-post' ); - expect( posts.length ).toBe( 1 ); + // Wait for the editor iframe to load, and switch to it as the active content frame. + const editorFrame = await page.waitForSelector( 'iframe[name="editor-canvas"]' ); - const [ firstPost ] = posts; + const innerFrame = await editorFrame.contentFrame(); - // Expect the title of the post to be correct. - const postTitle = await firstPost.$x( - `//a[contains(@class, "row-title")][contains(text(), "${ title }")]` + // Wait for title field to render onscreen. + await innerFrame.waitForSelector( '.editor-post-title__input' ); + + // Expect to now be in the editor with the correct post title shown. + const editorPostTitleInput = await innerFrame.$x( + `//h1[contains(@class, "editor-post-title__input")][contains(text(), "${ title }")]` ); expect( postTitle.length ).toBe( 1 ); } );