js调用webdriver怎么加载stealthminljs
可以使用以下代码加载stealth.minl.js文件:
const fs = require('fs');
const webdriver = require('selenium-webdriver');
// 读取stealth.minl.js文件内容
const stealthScript = fs.readFileSync('path/to/stealth.minl.js', 'utf8');
// 添加JavaScript代码到webdriver实例中
const driver = new webdriver.Builder()
.forBrowser('chrome')
.setChromeOptions(new chrome.Options().addArguments(`--disable-blink-features=AutomationControlled`))
.build();
driver.executeScript(stealthScript);
这里使用了Node.js的fs模块来读取文件内容,并使用executeScript方法将内容添加到webdriver实例中。注意,这里的路径需要根据实际情况进行修改
原文地址: https://www.cveoy.top/t/topic/gEz0 著作权归作者所有。请勿转载和采集!