admin管理员组文章数量:1122832
I am using Puppeteer for browser automation, and I encounter a popup in Chrome that says:
"Change your password. The password you just used was exposed in a data breach. Change it now in Google Password Manager."
I tried to disable this popup by passing the following arguments when launching the browser:
Args = new[]
{
"--disable-features=PasswordLeakDetection", // Disables password leak detection
"--no-sandbox", // For easier execution in Docker
"--disable-save-password-bubble" // Disables save password prompts
}
However, the popup still appears.
My Questions: How can I completely disable this popup in Chrome using Puppeteer? Is it possible to programmatically remove this popup using selectors or any other logic in Puppeteer?
Additional Info:
Puppeteer version: 20.0.5
Chrome version: 131.0.6778.86
Operating System: Windows
Thank you for your help!
using PuppeteerSharp;
using System.Collections.Generic;
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Threading;
class Program
{
public static async Task Main(string[] args)
{
var stopwatch = Stopwatch.StartNew();
var browserTasks = new List<Task>();
for (int browserIndex = 1; browserIndex <= 3; browserIndex++)
{
int tabCount = 5;
browserTasks.Add(Task.Run(async () =>
{
var browser = await Puppeteer.LaunchAsync(new LaunchOptions
{
ExecutablePath = @"C:\Program Files\Google\Chrome\Application\chrome.exe",
Headless = false,
Args = new[]
{
"--disable-features=PasswordLeakDetection", // Disables password leak detection
"--no-sandbox", // For easier execution in Docker
"--disable-save-password-bubble" // Disables save password prompts
},
DefaultViewport = null
});
var tabTasks = new List<Task>();
for (int tabIndex = 1; tabIndex <= tabCount; tabIndex++)
{
int counterTab = tabIndex;
tabTasks.Add(Task.Run(async () =>
{
var page = await browser.NewPageAsync();
await page.SetRequestInterceptionAsync(true);
page.Request += async (sender, e) =>
{
var headers = e.Request.Headers;
headers["Cache-Control"] = "no-cache, no-store, must-revalidate";
headers["Pragma"] = "no-cache";
headers["Expires"] = "0";
await e.Request.ContinueAsync(new Payload { Headers = headers });
};
await page.GoToAsync(";);
await page.TypeAsync("#user-name", "standard_user");
await page.TypeAsync("#password", "secret_sauce");
await page.ClickAsync("[name='login-button']");
Console.WriteLine($"Browser {browserIndex}, Tab {counterTab}: Login executed.");
//await page.CloseAsync();
}));
}
await Task.WhenAll(tabTasks);
//await browser.CloseAsync();
}));
}
await Task.WhenAll(browserTasks);
stopwatch.Stop();
Console.WriteLine($"All tasks completed in {stopwatch.ElapsedMilliseconds} ms.");
Console.ReadLine();
}
}
I am using Puppeteer for browser automation, and I encounter a popup in Chrome that says:
"Change your password. The password you just used was exposed in a data breach. Change it now in Google Password Manager."
I tried to disable this popup by passing the following arguments when launching the browser:
Args = new[]
{
"--disable-features=PasswordLeakDetection", // Disables password leak detection
"--no-sandbox", // For easier execution in Docker
"--disable-save-password-bubble" // Disables save password prompts
}
However, the popup still appears.
My Questions: How can I completely disable this popup in Chrome using Puppeteer? Is it possible to programmatically remove this popup using selectors or any other logic in Puppeteer?
Additional Info:
Puppeteer version: 20.0.5
Chrome version: 131.0.6778.86
Operating System: Windows
Thank you for your help!
using PuppeteerSharp;
using System.Collections.Generic;
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Threading;
class Program
{
public static async Task Main(string[] args)
{
var stopwatch = Stopwatch.StartNew();
var browserTasks = new List<Task>();
for (int browserIndex = 1; browserIndex <= 3; browserIndex++)
{
int tabCount = 5;
browserTasks.Add(Task.Run(async () =>
{
var browser = await Puppeteer.LaunchAsync(new LaunchOptions
{
ExecutablePath = @"C:\Program Files\Google\Chrome\Application\chrome.exe",
Headless = false,
Args = new[]
{
"--disable-features=PasswordLeakDetection", // Disables password leak detection
"--no-sandbox", // For easier execution in Docker
"--disable-save-password-bubble" // Disables save password prompts
},
DefaultViewport = null
});
var tabTasks = new List<Task>();
for (int tabIndex = 1; tabIndex <= tabCount; tabIndex++)
{
int counterTab = tabIndex;
tabTasks.Add(Task.Run(async () =>
{
var page = await browser.NewPageAsync();
await page.SetRequestInterceptionAsync(true);
page.Request += async (sender, e) =>
{
var headers = e.Request.Headers;
headers["Cache-Control"] = "no-cache, no-store, must-revalidate";
headers["Pragma"] = "no-cache";
headers["Expires"] = "0";
await e.Request.ContinueAsync(new Payload { Headers = headers });
};
await page.GoToAsync("https://www.saucedemo.com");
await page.TypeAsync("#user-name", "standard_user");
await page.TypeAsync("#password", "secret_sauce");
await page.ClickAsync("[name='login-button']");
Console.WriteLine($"Browser {browserIndex}, Tab {counterTab}: Login executed.");
//await page.CloseAsync();
}));
}
await Task.WhenAll(tabTasks);
//await browser.CloseAsync();
}));
}
await Task.WhenAll(browserTasks);
stopwatch.Stop();
Console.WriteLine($"All tasks completed in {stopwatch.ElapsedMilliseconds} ms.");
Console.ReadLine();
}
}
Share
Improve this question
edited Nov 28, 2024 at 2:32
Md. Abu Taher
18.8k5 gold badges57 silver badges78 bronze badges
asked Nov 22, 2024 at 14:10
LexxxaLexxxa
11 bronze badge
3
- You should add a minimal reproducable code, I just tested a script with a demo url, and it totally worked, no password leak message, nothing. demo.wpjobboard.net/wp-admin/admin.php?page=wpjb-job – Md. Abu Taher Commented Nov 26, 2024 at 6:47
- I was getting this error on saucedemo.com, the site is specifically made just for automated testing. And getting that prompt from chrome is not constant. My code works in multithreading, maybe that's the problem. – Lexxxa Commented Nov 26, 2024 at 10:31
- I was able to reproduce this issue. Let me see. – Md. Abu Taher Commented Nov 28, 2024 at 2:08
1 Answer
Reset to default 0For me this did not happen with the original puppeteer written in JS. However I could see this became an issue on the puppeteer-sharp version even though it set the flags correctly.
For now, The solution seem to be disabling the message center popups altogether, which can be done with suppress-message-center-popups chrome flag.
Here is how I used this in the code,
var browser = await Puppeteer.LaunchAsync(new LaunchOptions
{
Headless = false,
Args = ["--suppress-message-center-popups"]
});
Result,
本文标签:
版权声明:本文标题:Puppeteer: How to Disable "Change Your Password" (Password Leak Detection) Popup in Chrome? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736303236a1931815.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论