How to use puppeteer inside codecept?

55 views Asked by At

I currently have a Jest + Puppeteer file where I retrieve the email from [https://temp-mail.org/es/ ] and click on the link of the mail received. This was only possible by using the StealthPlugin from puppeteer-extra. If I don't use StealthPlugin, the website blocks me and doesn't allow me to click on the email link.

Now, I am writing a similar file using Codecept.js, but it is blocking me because I don't have StealthPlugin. How can I make Codecept.js + Puppeteer use StealthPlugin?

Here is my code using Codecept.js:

visit() {
  session('getEmail', () => {
    I.amOnPage('https://temp-mail.org/es/');
  });
}

I get the email and fill in a form and then call this other function to confirm the email received.

confirmGetDataEmail() {
  I.waitForElement(this.confirmEmail, 60);
  I.click(this.confirmEmail);
  I.click(this.confirmButton);
}

When I execute I.click(this.confirmEmail), I encounter an error.

error

I tried installing StealthPlugin and I added it to the js file

const StealthPlugin = require('puppeteer-extra-plugin-stealth')
puppeteer.use(StealthPlugin())

and inside confirmGetDataEmail I modyfied it like this:

async confirmGetDataEmail() {
 browser = await puppeteer.launch
 page = await browser.newPage()
 await page.waitForXPath(this.confirmEmail);
  await page.click(this.confirmEmail);
  I.click(this.confirmButton);
}

but it doesn't work.

0

There are 0 answers