Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make clickOnMoreMenuItem not dependent on aria labels #13166

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions packages/e2e-test-utils/src/click-on-more-menu-item.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* External dependencies
*/
import { first } from 'lodash';

/**
* Clicks on More Menu item, searches for the button with the text provided and clicks it.
*
Expand All @@ -7,7 +12,18 @@ export async function clickOnMoreMenuItem( buttonLabel ) {
await expect( page ).toClick(
'.edit-post-more-menu [aria-label="Show more tools & options"]'
);
await page.click(
`.edit-post-more-menu__content button[aria-label="${ buttonLabel }"]`
);
const moreMenuContainerSelector =
'//*[contains(concat(" ", @class, " "), " edit-post-more-menu__content ")]';
let elementToClick = first( await page.$x(
`${ moreMenuContainerSelector }//button[contains(text(), "${ buttonLabel }")]`
) );
// If button is not found, the label should be on the info wrapper.
if ( ! elementToClick ) {
elementToClick = first( await page.$x(
moreMenuContainerSelector +
'//button' +
`/*[contains(concat(" ", @class, " "), " components-menu-item__info-wrapper ")][contains(text(), "${ buttonLabel }")]`
) );
}
await elementToClick.click();
}