Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Warning: Plugin is not derived from PuppeteerExtraPlugin, ignoring." #503

Closed
micha1333 opened this issue May 21, 2021 · 14 comments
Closed
Labels
issue: bug report A bug has been reported needs triage

Comments

@micha1333
Copy link

micha1333 commented May 21, 2021

Hello,
I have tried to add a plugin '@extra/humanize'.
But I got a warning as the following

Warning: Plugin is not derived from PuppeteerExtraPlugin, ignoring. HumanizePlugin {
_debugBase: [Function: debug] {
namespace: 'automation-extra-plugin:base:humanize',
useColors: true,
color: 3,
extend: [Function: extend],
destroy: [Function: deprecated],
enabled: [Getter/Setter],
inspectOpts: {}
},
_opts: { mouse: { enabled: true, showCursor: false } },
env: LauncherEnv { driverName: 'unknown', browserName: 'unknown' }
}

My code
const puppeteer = require('puppeteer-extra')
const HumanizePlugin =require('@extra/humanize')
puppeteer.use(HumanizePlugin())

Here is the link of the plugin
https://www.npmjs.com/package/@extra/humanize

@micha1333 micha1333 added issue: bug report A bug has been reported needs triage labels May 21, 2021
@abokizh
Copy link

abokizh commented May 22, 2021

const HumanizePlugin = require('@extra/humanize')
HumanizePlugin()._isPuppeteerExtraPlugin = true;
puppeteer.use(
    HumanizePlugin({
        mouse: {
            showCursor: true // Show the cursor (meant for testing)
        }
    })
)

@micha1333
Copy link
Author

const HumanizePlugin = require('@extra/humanize')
HumanizePlugin()._isPuppeteerExtraPlugin = true;
puppeteer.use(
HumanizePlugin({
mouse: {
showCursor: true // Show the cursor (meant for testing)
}
})
)

@micha1333 micha1333 reopened this May 22, 2021
@micha1333
Copy link
Author

Thanks @abokizh,
I tried the code you provided me, but I got the same error.
I don't think it supports commonJS style. it seems like the package only supports ESM style.
I maybe wrong. Please guide me.
Thanks again

@kasjp
Copy link

kasjp commented May 23, 2021

Use Yarn to install "@next" packages instead of NPM
Note: sometimes you still need to re-add them after doing yarn install
yarn add @extra/humanize@next

@micha1333
Copy link
Author

Thanks @kasjp. I used yarn instead of npm and installed @extra/humanize@next.
But I am still facing the issue.
Could you please explain in deep?

@kasjp
Copy link

kasjp commented May 24, 2021

Thanks @kasjp. I used yarn instead of npm and installed @extra/humanize@next.

But I am still facing the issue.

Could you please explain in deep?

If you want deep explanation, you'll have to ask @berstend, if you haven't yet, install puppeteer-extra@next with yarn too. That fixed it for me

@micha1333
Copy link
Author

Thanks @kasjp again. it works for me. But I can not see mouse movement even though I added @extra/humanize plugin for puppeteer-extra. Can you help me?

@kasjp
Copy link

kasjp commented May 24, 2021

Thanks @kasjp again. it works for me. But I can not see mouse movement even though I added @extra/humanize plugin for puppeteer-extra. Can you help me?

If you have loaded it in and added it through puppeteer.use(), you won't see it by default but it's there. Check docs on how to enable the cursor visibility.

@micha1333
Copy link
Author

@kasjp My code is like the following
const HumanizePlugin = require('@extra/humanize')
puppeteer.use(
HumanizePlugin({
mouse: {
enabled: true,
showCursor: true // Show the cursor (meant for testing)
}
})
)

But I can not see mouse cursor. it is weird.

@kasjp
Copy link

kasjp commented May 24, 2021

@kasjp My code is like the following
const HumanizePlugin = require('@extra/humanize')
puppeteer.use(
HumanizePlugin({
mouse: {
enabled: true,
showCursor: true // Show the cursor (meant for testing)
}
})
)

But I can not see mouse cursor. it is weird.

@micha1333 Have you tried creating a new page? The plugins usually initialize onPageCreated, so calling browser.newPage() should force the plugins to load in the new page. Try this

// Load puppeteer
const puppeteer = require("puppeteer-extra");
//Load Humanize plugin
const HumanizePlugin = require("@extra/humanize");
//Load the plugin into puppeteer, show the cursor
puppeteer.use(
  HumanizePlugin({
    mouse: {
      enabled: true,
      showCursor: true
    },
  });
);
(async () => {
//Launch puppeteer
  let browser = await puppeteer.launch();
  //Get initial page
  let [page] = await browser.pages();
  //Create new page(this loads in plugins)
  let page2 = await browser.newPage();
  //close now not-needed first page
  await page.close();
  //do what you want with page2 now, I usually do this
  page = page2;
})();

@clouedoc
Copy link

Hello everyone!

Thanks for your comments on the issue, which allowed me to solve it on my side.

Here's what I used:

npm i puppeteer-extra@next
npm i @extra/humanize@next

@jonas-duarte
Copy link
Contributor

Hello everyone!

Thanks for your comments on the issue, which allowed me to solve it on my side.

Here's what I used:

npm i puppeteer-extra@next
npm i @extra/humanize@next

I am facing the following error after the steps:

An error occured clicking on "selector": TypeError: page._client.send is not a function
Skipping humanize and use vanilla click.

package.json

{
  "dependencies": {
    "@extra/humanize": "^4.2.2-next.616",
    "puppeteer": "^15.3.0",
    "puppeteer-extra": "^3.1.16-next.149",
    "puppeteer-extra-plugin-stealth": "^2.10.1"
  }
}
import { Browser, Page } from "puppeteer";
import puppeteer from "puppeteer-extra";
import StealthPlugin from "puppeteer-extra-plugin-stealth";
import HumanizePlugin from "@extra/humanize";

import { WebNavigator } from "./web-navigator";

puppeteer.use(StealthPlugin());

puppeteer.use(
  HumanizePlugin({
    mouse: {
      enabled: true,
      showCursor: true, // Show the cursor (meant for testing)
    },
  })
);

export class PuppeteerNavigator implements WebNavigator {
  static async make(): Promise<PuppeteerNavigator> {
    const browser = await puppeteer.launch({
      // @ts-ignore
      headless: false,
      args: ["--no-sandbox", "--disable-setuid-sandbox"],
    });

    const page = await browser.newPage();

    return new PuppeteerNavigator(browser, page);
  }

  constructor(private browser: Browser, private page: Page) {}

  async navigateTo(url: string): Promise<void> {
    await this.page.goto(url, { waitUntil: "networkidle0" });
  }

  async click(selector: string): Promise<void> {
    try {
      await this.page.waitForSelector(selector);
      await this.page.click(selector);
    } catch (error) {
      console.log("ERROR:", error);
    }
  }
}

Does anybody knows how to solve it?

@berstend
Copy link
Owner

berstend commented Jul 5, 2022

You are using the old automation-extra rewrite #454 which is not supported anymore. Playwright support has landed in #664 and made it obsolete. :)

There's no new humanize plugin yet, but it's planned. For the moment you can use the external ghost-cursor package.

@berstend berstend closed this as completed Jul 5, 2022
@brianjenkins94
Copy link

brianjenkins94 commented Apr 11, 2023

Where might I find the source for the humanize plugin?

This looks like it might be it: https://github.com/berstend/puppeteer-extra/tree/automation-extra/packages/plugin-humanize

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug report A bug has been reported needs triage
Projects
None yet
Development

No branches or pull requests

7 participants