我正在使用selenium C#,我试图禁用弹出的“崩溃的”铬:

我试着设置配置文件首选项,但它似乎根本没有改变,代码:
ChromeOptions options = new ChromeOptions();
options.AddUserProfilePreference("exit_type", "Normal");
options.AddUserProfilePreference("exited_cleanly", "true");
IWebDriver driver = new ChromeDriver(options);我尝试将exit type的值更改为none & None,但在preferences文档中没有做任何更改。
发布于 2020-06-09 17:44:06
我正在使用C#,并且我注意到只有当我们在finally块中使用Close()方法和Quit()方法时,chrome驱动程序才能被关闭。不需要特殊选项。我想在java中也是一样的。这将有助于摆脱“恢复页面”,同时启动chrome的驱动程序
ChromeOptions options = new ChromeOptions();
options.AddArgument(Configure.chromeProfileDir);
options.AddArgument(Configure.chromePath);
ChromeDriver d = null;
try
{
d = new ChromeDriver(options);
d.Navigate().GoToUrl("https://google.com");
// Your operations...
}
catch(Exception e)
{
// Handle your exceptions...
}
finally
{
try
{
d.Close();
d.Quit();
}
catch(Exception e)
{
}
}发布于 2021-05-20 10:27:47
我测试了@Icy给出的答案,它对我很有效。我使用的是:
prefs = {'exit_type': 'Normal'}
option.add_experimental_option("prefs", {'profile': prefs})https://superuser.com/a/1343331提到,唯一的问题是这里列出的方法,你每次都需要手动编辑文件,所以这个方法效果更好,在2021年5月进行了测试。因为我还没有名气,所以不能给答案加分,而且这是最后一个答案。
发布于 2018-07-14 21:39:02
使用以下代码处理此弹出窗口:
ChromeOptions options = new ChromeOptions();
options.AddArguments("--disable-extensions");
options.AddArguments("--disable-application-cache");
driver = new ChromeDriver(options);https://stackoverflow.com/questions/51269896
复制相似问题