Alorain
Alorain

Reputation: 1

CodeceptJS - canvas manipulation

I am writing an E2E test for our application. On one page there is a canvas that is showing a PDF file. The test case is show this page, scroll to the bottom of the PDF and check if the button under the canvas is no longer disabled. Imagine a common licence agreements window in some application or software installation.

The problem is I have no idea how to scroll down in said canvas. It is not in iframe, so I cant switch into it. Functions provided by CodeceptJS scrolls only on the page and not on the canvas.

Has anyone did something familiar and know how to do this?

Upvotes: 0

Views: 192

Answers (1)

Alorain
Alorain

Reputation: 1

Found a solution!

I.useWebDriverTo('scroll to bottom of the amendment canvas', async ({ browser }) => {
  const canvas = await browser.$('#amendment-preview > canvas')
  const button = await browser.$('button[data-qa="confirm-amendment-button"]')
  canvas.click()
  while (await button.getAttribute('disabled')) {
    await browser.keys('ArrowDown')
  }
})

Upvotes: 0

Related Questions