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

530 Views Asked by At

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?

3

There are 3 best solutions below

2
VonC On

Check first if a --no-first-run flag to disable the first-time run experience in Chrome would work better in your case:

chrome.exe --no-first-run

Add this flag to the TestComplete settings, where you configure the browser for automated tests.

Another approach is to set up a Chrome user profile that has already dismissed this dialog. You can then launch Chrome with that user profile using the --user-data-dir flag.

chrome.exe --user-data-dir="path/to/custom/profile"

You would upload this Chrome profile to the Azure Pipeline's workspace, and reference it when running your tests.


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...

While that is a valid approach, it may introduce unnecessary complexity and maintenance overhead to your test suites. Still, it is a good fallback option if the dialog cannot be disabled through other means.

In your Azure Pipeline YAML, you may include a step that configures Chrome appropriately before your tests run:

steps:
- script: 'chrome.exe --no-first-run'
  displayName: 'Configure Chrome'
  
# Your TestComplete task here

Or if using a pre-configured profile:

steps:
- script: 'chrome.exe --user-data-dir="path/to/custom/profile"'
  displayName: 'Configure Chrome'
  
# Your TestComplete task here
0
Bob On

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!

0
Suresh On

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.