disable-infobars argument unable to hide the infobar with the message “Chrome is being controlled by automated test software” with ChromeDriver v2.36

自作多情 提交于 2020-05-23 09:50:12

问题


I just updated ChromeDriver to newest version - 2.36. In previous versions I've set:

    ChromeOptions options = new ChromeOptions();
    options.addArguments("disable-infobars");

and the "Chrome is being controlled by automated test software" warning bar wasn't displayed. With the same option set, I'm keep seeing it. Do you know how to disable this from appearing in the newest ChromeDriver? Thanks in advance


回答1:


disable-infobars flag has been removed in latest Chrome => https://chromium.googlesource.com/chromium/src/+/d869ab3350d8ebd95222b4a47adf87ce3d3214b1




回答2:


disable-infobars flag has been removed but you can get rid of the message by adding the following:

ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("useAutomationExtension", false);
options.setExperimentalOption("excludeSwitches",Collections.singletonList("enable-automation"));    
WebDriver driver = new ChromeDriver(options);

This work for me and I hope works for you too.




回答3:


I was able to get rid of the message by adding the following...

    chromeOptions.AddExcludedArgument("enable-automation")

This in turn causes a popup in Chrome titled "Disable developer mode extensions". I am able to close this popup in VB.NET by calling CloseChromeDialogDisableDeveloperModeExtensions() method below at the appropriate time(s).

I hope this helps!

    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



回答4:


New version of ChromeDriver has been released - 2.37. It again supports:

options.addArguments("disable-infobars");



回答5:


You saw it right.

Passing the argument disable-infobars no more suppresses the infobar with text as Chrome is being controlled by automated test software with ChromeDriver v2.36.

As per https://crrev.com/528386 the flag --disable-infobars was removed on Wed Jan 10 19:44:29 2018 as this flag is no longer needed by the perf testing infrastructure and can be misused for malicious purposes, so remove it.

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

This change landed with ChromeDriver v2.36 on 2018-03-02 which supported Chrome v63-65. Hence while using ChromeDriver v2.36 the infobar is no more getting supressed.


But as per Infobars cannot be disabled - breaks coordinate assumptions in Selenium tests the --disable-infobars was back on Mar 20 2018.

Solution

With ChromeDriver v2.36 if you are unable to supress the infobar with text as Chrome is being controlled by automated test software, you need to upgrade to ChromeDriver v2.38 of 2018-04-17 which supported Chrome v65-67




回答6:


Use this code. It works fine

`ChromeOptions options = new ChromeOptions(); 
        options.addArguments("disable-infobars"); 
        WebDriver driver = new ChromeDriver(options);`



回答7:


A latest working example in Java:

options.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
options.setExperimentalOption("useAutomationExtension", false);

Tested in Chrome Version 80



来源:https://stackoverflow.com/questions/49169990/disable-infobars-argument-unable-to-hide-the-infobar-with-the-message-chrome-is

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!