Skip to main content

isEqual

Overview​

Use the isEqual command to compare a specified DOM element with another element.

The command returns true if the selected element matches the provided one; otherwise, it returns false.

Usage​

await browser.$(selector).isEqual(el);

Command Parameters​

NameTypeDescription
elElementThe element to compare with.

Usage Examples​

it("should detect if an element is equal to another", async ({ browser }) => {
const el = await browser.$("#el");

const sameEl = await browser.$("#el");
const anotherEl = await browser.$("#anotherEl");

el.isEqual(sameEl); // outputs: true
el.isEqual(anotherEl); // outputs: false
});

References​

We'd like to give credit to the original WebdriverIO docs article, from which we drew some information while writing our version.