Skip to content
Advertisement

Unable to get isDisabled() to work in Playwright

I need to check that a button is disabled (checking for a last page of a table). There are two with the same id (top and bottom of the table).

const nextPageButtons = await this.page.$$('button#_btnNext'); // nextPageButtons.length is 2, chekced via console.log
const nextPageButtonState = await nextPageButtons[0].isDisabled();

But when I do the above I get: elementHandle.isDisabled: Unable to adopt element handle from a different document.

Why doesn’t this work?

Advertisement

Answer

So, this works:

const nextPageButtons = await this.page.$$('button#_btnNext');
const nextPageButton1 = await nextPageButtons[0];
const nextPageButton1State = await nextPageButtonsState.isDisabled();
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement