gpt4 book ai didi

ghost-cursor Error : elem.remoteObject is not a function in puppeteer(Ghost-Cursor错误:elem.emoteObject不是puppeteer中的函数)

翻译 作者:bug小助手 更新时间:2023-10-26 22:33:15 28 4
gpt4 key购买 nike



whenever I run the script in the Local system the cursor properly worked and when I run inside docker that time I fetch an Error so anybody guid me what is wrong or whether this issue is package side or not.?

每当我在本地系统中运行脚本时,游标都能正常工作,当我在docker中运行时,我获取了一个错误,所以任何人都会告诉我哪里出了问题,或者这个问题是不是包端的问题。


when I run in Locally that time I headless: false and Run inside docker that time headless: true but I tried inside docker headless: false but it can't work

当我在当地跑的时候,我无头:假,当时无头:真的,但我试过了,无头:假,但它不能工作


here is code

以下是代码


const puppeteer = require('puppeteer');
const {path,createCursor} = require("ghost-cursor");
const url = process.argv[2];

async function run() {
browser = await puppeteer.launch({
args: ['--disable-gpu', '--no-first-run', '--no-sandbox', '--no-zygote'],
"dumpio": true,
"devtools": false,
"ignoreHTTPSErrors": true,
});

const page = await browser.newPage();
const cursor = createCursor(page);
await cursor.move(selector)
await page.goto(url);
await page.screenshot({ path: 'screenshot.png' });
browser.close();
}
run();

Here is Error Message

TypeError: elem.remoteObject is not a function
at Object.<anonymous> (/usr/app/node_modules/ghost-cursor/lib/spoof.js:458:61)
at step (/usr/app/node_modules/ghost-cursor/lib/spoof.js:44:23)
at Object.next (/usr/app/node_modules/ghost-cursor/lib/spoof.js:25:53)
at fulfilled (/usr/app/node_modules/ghost-cursor/lib/spoof.js:16:58)
at processTicksAndRejections (internal/process/task_queues.js:95:5)

更多回答
优秀答案推荐

selector is undefined

选择器未定义


You need to grab an element from the UI to move to like so

您需要从UI中抓取一个元素才能移动到,如下所示


import { createCursor } from "ghost-cursor"
import puppeteer from "puppeteer"

const run = async (url) => {
const selector = "#sign-up button"
const browser = await puppeteer.launch({ headless: false });
const page = await browser.newPage()
const cursor = createCursor(page)
await page.goto(url)
await page.waitForSelector(selector)
await cursor.click(selector)
}


This must be happening due to version discrepancies with the way remoteObject can be accessed. The temporary solution I arrived at was to modify the source code.

这一定是由于访问远程对象的方式的版本不一致造成的。我得出的临时解决方案是修改源代码。


Go to /node_modules/ghost-cursor/lib/spoof.js and change the references from .remoteObject().objectId to ._remoteObject.objectId.

转到/NODE_MODULES/GHOST-CURSOR/lib/spoof.js并将引用从.emoteObject().objectId更改为._emoteObject.objectId。


Obviously modifying code from your deps is a bad idea, but I couldn't find the right solution anywhere.

显然,从你的deps修改代码是一个坏主意,但我找不到正确的解决方案。


更多回答

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com