我刚刚将ChromeDriver更新到最新版本 - 2.36。 在以前的版本中,我设置了:
ChromeOptions options = new ChromeOptions();
options.addArguments("disable-infobars");
和" Chrome由自动化测试软件控制"警告栏未显示。使用相同的选项集,我会继续看到它。你知道如何禁用它出现在最新的ChromeDriver中吗? 提前致谢
答案 0 :(得分:4)
disable-infobars
标记https://chromium.googlesource.com/chromium/src/+/d869ab3350d8ebd95222b4a47adf87ce3d3214b1
答案 1 :(得分:1)
你看对了。
通过 ChromeDriver v2.36 传递参数disable-infobars
不再抑制带有 Chrome is being controlled by automated test software
文本的信息栏
根据https://crrev.com/528386标记--disable-infobars
已于 Wed Jan 10 19:44:29 2018 删除,因为此测试基础设施不再需要此标记,并且可以被滥用于恶意目的,所以删除它。
Remove --disable-infobars.
This flag is no longer needed by the perf testing infrastructure and can be
misused for malicious purposes, so remove it.
BUG=none
TEST=none
此更改与 2018-03-02 上的 ChromeDriver v2.36 相关,后者支持 Chrome v63-65 。因此,在使用 ChromeDriver v2.36 时,信息栏不再受到压制。
但根据Infobars cannot be disabled - breaks coordinate assumptions in Selenium tests, --disable-infobars
重新回到 2018年3月20日。
使用 ChromeDriver v2.36 ,如果您无法使用 Chrome is being controlled by automated test software
的文字来压制信息栏,则需要升级 2018-04-17 ChromeDriver v2.38
,支持 Chrome v65-67
答案 2 :(得分:1)
我能够通过添加以下内容来消除此消息......
chromeOptions.AddExcludedArgument("使自动化&#34)
这反过来导致Chrome中的弹出窗口标题为"禁用开发者模式扩展"。我可以通过在适当的时间调用CloseChromeDialogDisableDeveloperModeExtensions()方法在VB.NET中关闭这个弹出窗口。
我希望这有帮助!
Private Declare Auto Function FindWindow Lib "user32.dll" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (hWnd As IntPtr, wMsg As Int32, wParam As Int32, lParam As String) As Int32
Private Sub CloseChromeDialogDisableDeveloperModeExtensions()
Try
Const WM_CLOSE As Integer = 16
Dim popupHandle As IntPtr = FindWindow("Chrome_WidgetWin_1", "Disable developer mode extensions")
If popupHandle <> New IntPtr(0) Then
SendMessage(popupHandle, WM_CLOSE, 0, Nothing)
End If
Catch ex As Exception
'swallow exception
End Try
End Sub
答案 3 :(得分:1)
disable-infobars
标志已被删除,但您可以通过添加以下内容来删除该消息:
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("useAutomationExtension", false);
options.setExperimentalOption("excludeSwitches",Collections.singletonList("enable-automation"));
WebDriver driver = new ChromeDriver(options);
这项工作对我而言,我也希望对你有用。
答案 4 :(得分:1)
新版ChromeDriver已发布 - 2.37。 它再次支持:
enum class
答案 5 :(得分:0)
使用此代码。它工作正常
`ChromeOptions options = new ChromeOptions();
options.addArguments("disable-infobars");
WebDriver driver = new ChromeDriver(options);`
答案 6 :(得分:0)
Java中最新的工作示例:
options.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
options.setExperimentalOption("useAutomationExtension", false);
在Chrome版本80中测试
答案 7 :(得分:0)
简化的解决方案:
options.setExperimentalOption("excludeSwitches", new String[]{"enable-automation"});