在尝试使Puppeteer在带有用户数据的现有chrome窗口中运行时,我遇到了很多问题。我试图简化事情,这是我当前的代码。我已经尝试了所有与该问题相关的事情,所以不知道该怎么办:
const browser = await puppeteer.launch({
headless: false,
userDataDir: 'C:\\Users\\me\\AppData\\Local\\Google\\Chrome\\User Data'
})
const page = await browser.newPage();
这会导致以下错误:
error Error: Failed to launch chrome!
[8084:14860:0321/091939.752:ERROR:cache_util_win.cc(19)] Unable to move the cach
e: 0
[8084:14860:0321/091939.752:ERROR:cache_util.cc(140)] Unable to move cache folde
r C:\Users\me\AppData\Local\Google\Chrome\User Data\ShaderCache\GPUCache
to C:\Users\me\AppData\Local\Google\Chrome\User Data\ShaderCache\old_GP
UCache_000
[8084:14860:0321/091939.752:ERROR:disk_cache.cc(184)] Unable to create cache
[8084:14860:0321/091939.752:ERROR:shader_disk_cache.cc(622)] Shader Cache Creati
on failed: -2
答案 0 :(得分:1)
问题与打开的Chrome进程有关。确保在任务管理器中关闭所有它们,以下内容将起作用:
browser = await puppeteer.launch({
headless: false,
executablePath: `C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe`,
userDataDir: `C:\\Users\\Marwan\\AppData\\Local\\Google\\Chrome\\User Data`,
});