Skip to content

Commit

Permalink
Revert "Catch if an element is not clickable (#141)"
Browse files Browse the repository at this point in the history
This reverts commit 185b471.
  • Loading branch information
ebebbington committed Apr 29, 2024
1 parent 185b471 commit b49f838
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 45 deletions.
26 changes: 7 additions & 19 deletions src/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,19 +260,13 @@ export class Element {
if (!options.button) options.button = "left";

// Scroll into view
try {
await this.#page.evaluate(
`${this.#method}('${this.#selector}').scrollIntoView({
block: 'center',
inline: 'center',
behavior: 'instant'
})`,
);
} catch (_e) {
await this.#page.client.close(
`The given element ("${this.#selector}") is no longer present in the DOM`,
);
}
await this.#page.evaluate(
`${this.#method}('${this.#selector}').scrollIntoView({
block: 'center',
inline: 'center',
behavior: 'instant'
})`,
);

// Get details we need for dispatching input events on the element
const result = await this.#protocol.send<
Expand All @@ -285,12 +279,6 @@ export class Element {
null,
ProtocolTypes.Page.GetLayoutMetricsResponse
>("Page.getLayoutMetrics");
if (!result || !result.quads.length) {
await this.#page.client.close(
`Node is either not clickable or not an HTMLElement`,
);
}

// Ignoring because cssLayoutMetrics is present on chrome, but not firefox
// deno-lint-ignore ban-ts-comment
// @ts-ignore
Expand Down
26 changes: 0 additions & 26 deletions tests/unit/element_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,6 @@ const serverAdd = `http://${
for (const browserItem of browserList) {
Deno.test(browserItem.name, async (t) => {
await t.step("click()", async (t) => {
await t.step(
"It should fail if the element is no longer present in the DOM",
async () => {
const { page } = await buildFor(browserItem.name, {
remote,
});
await page.location("https://drash.land");
// Need to make the element either not clickable or not a HTMLElement
const selector = 'a[href="https://discord.gg/RFsCSaHRWK"]';
const elem = await page.querySelector(
selector,
);
await page.location("https://google.com");
let errMsg = "";
try {
await elem.click();
} catch (e) {
errMsg = e.message;
}
assertEquals(
errMsg,
`The given element ("${selector}") is no longer present in the DOM`,
);
},
);

await t.step(
"It should allow clicking of elements and update location",
async () => {
Expand Down

0 comments on commit b49f838

Please sign in to comment.