Stop Chrome opening with "Turn on an ad privacy feature" in Azure Pipeline
Asked Answered
M

4

6

I'm attempting to run a TestComplete automated test project on a Microsoft Azure Hosted agent using the windows-latest image. The test never finishes and eventually the 60 minute job timeout kicks in.

I have reduced my test timeout to 5 minutes and uploaded the Test Visualiser screenshots to a pipeline artifact and I can see that my tests are failing because Chrome is showing a first-time "Turn on an ad privacy feature" dialog box over the top of my application.

Is there a command line I can call to disable this ahead of running my tests? Or do I need to code in specific checks in my test-suite to manually clear this dialog?

Muster answered 12/9, 2023 at 13:19 Comment(1)
To update on this, we're attempting to build functions into TestComplete to find and dismiss this window which we'll have to include at the start of every test...Muster
I
0

I was doing some reading and came across the following:

https://www.ghacks.net/2023/07/18/how-to-turn-off-google-chromes-built-in-advertising-features/

Google has started to display popups in Chrome to users that inform users about the new technology. Google, obviously, calls it "enhanced ad privacy in Chrome" or "turn on an ad privacy feature", which most users who do not follow privacy news online may happily agree to.

Doing a little further research I came across the following:

https://www.ghacks.net/2023/07/01/all-chrome-users-will-see-popups-in-the-coming-weeks-here-is-why/

leading me here:

Reacted? Yes, because the popup is not a normal popup that one can dismiss by closing the tab or navigating away. The entire browser is locked when the popup is displayed and will only be unlocked once Chrome users respond to it. Note that it is not even possible to move the Chrome window or resize it. Every action is locked.

Two thoughts came to mind, changing the version of Chrome...or the more annoying option setting up the test script to click through the actions. Best of luck!

Iatrochemistry answered 29/9, 2023 at 4:15 Comment(0)
J
0

The following script works for me when running on a Microsoft Hosted 'windows-latest' agent. Currently these agents are Windows Server 2022, with Google Chrome 126.0.6478.115. Of course, in later versions of Chrome the initial dialogs may change.

NB - the script uses OCR. You will need the TestComplete Intelligent Quality add-on.

Tweak the delays and screenshot logging as you see fit.

function ChromeFirstTimeSetup()
{
  //Launch Chrome for the first time
  Browsers.Item(btChrome).Run();
  Delay(20000);
  Log.Picture(Aliases.browser.BrowserWindow.Picture(), "", "");

  //Dismiss the separate "Sign in to Chrome" dialog
  Aliases.browser.BrowserWindow.Chrome_RenderWidgetHostHWND.SetFocus();
  OCR.Recognize(Aliases.browser.BrowserWindow.Chrome_RenderWidgetHostHWND).BlockByText("Don't sign in").Click();  
  Delay(5000);
  Log.Picture(Aliases.browser.BrowserWindow.Picture(), "", "");
  
  //Now in Chrome, dismiss the "Turn on an ad privacy feature" dialog 
  OCR.Recognize(Aliases.browser.wndChrome_WidgetWin_1).BlockByText("No thanks").Click();  
  Delay(5000);
  Log.Picture(Aliases.browser.BrowserWindow.Picture(), "", "");
  
  //Acknowledge the "Other ad privacy features now available" dialog
  OCR.Recognize(Aliases.browser.wndChrome_WidgetWin_1).BlockByText("Got it").Click();  
  Delay(5000);
  Log.Picture(Aliases.browser.BrowserWindow.Picture(), "", "");
}
Jobber answered 26/6 at 9:15 Comment(0)
A
0

You can disable the Chrome sign in, save password and privacy feature dialogs via registry entries. (Tested on Azure, Windows 10 image with Chrome 126.) This is especially useful for those of us who don't want to use OCR or generally don't want to have extra steps in test automation because of the annoying dialogs mentioned.

If you set the following registry values to zero (REG_DWORD 0x0), the dialogs will not appear.

Key:

HKEY_LOCAL_MACHINE\Software\Policies\Google\Chrome

Values:

BrowserSignin
PasswordManagerEnabled
PrivacySandboxPromptEnabled

Documentation: BrowserSignin, PasswordManagerEnabled and PrivacySandboxSiteEnabledAdsEnabled

Because the values are under HKEY_LOCAL_MACHINE you have to write them with admin rights. In our azure pipeline, there is a power-shell custom script that is executed with admin rights at the beginning, i.e. when the image is started. We set the values there:

reg add "HKEY_LOCAL_MACHINE\Software\Policies\Google\Chrome" /v BrowserSignin /t REG_DWORD /d 0 /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome" /v PasswordManagerEnabled /t REG_DWORD /d 0 /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome" /v PrivacySandboxPromptEnabled /t REG_DWORD /d 0 /f

We have inserted a control output in the batch file with which we start TestComplete to see whether the settings have actually been made:

REG QUERY "HKEY_LOCAL_MACHINE\Software\Policies\Google\Chrome" /v BrowserSignin
REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome" /v PasswordManagerEnabled
REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome" /v PrivacySandboxPromptEnabled

I hope this helps you.

Anglomania answered 24/7 at 13:18 Comment(0)
P
-1

I tried the way suggested by @VonC but somehow didn't worked for me. First option didn't worked. Second option not sure how I can give path to profile when its running in CI(since user value would be unknown). I tried uploading my own custom profile in project and providing that path, but unfortunately didn't worked.

Here's the solution which I did and solved issue.

  1. Create a new profile in chrome locally.

  2. Launch Chrome > Select the newly created profile.

  3. Observe ad privacy window pops up.

  4. In TestComplete create new keyword test and start recording.

  5. Record the chrome screen and hit tab 3 times so that Got it option is highlighted. And press enter

  6. Now this gets recorded and will have namemapping something like thisenter image description here

  7. Now add Events and select OnLogError

  8. Create new function where you enter this code.

    function EventControl1_OnLogError(Sender, LogParams) { Aliases.browser.wndChrome_WidgetWin_1.Keys("[Tab][Tab][Tab][Enter]"); Aliases.browser.BrowserWindow.Maximize(); }

  9. Now create one common test which launched the browser and place that test in execution plan at beginning. Unmark it as testcase so that it doesn't counts toward your test summary.

  10. During running what happens is your first test (which is launching browser) gets executed and since it will have ad screen it will try OnLogError and after passing keys it fails. But the actual your test which begins from second test in execution plan now when launches the browser you will have it in the state where Ad setting is completed so problem gets solved.

  11. Sometime it might not work (in my case 1st test was passing only 2nd test onward disabled error was shown). In such case try putting the test at step 9 to be placed twice in execution plan.

Pyretotherapy answered 18/10, 2023 at 5:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.