[error] No tab with id: *randomNumber*

Let me explain my case:

I use Task Scheduler to open a ps1 file by powershell.
And that ps1 file has a script that:

  • Open a Chrome Profile, access Youtube.
  • Wait for 20 seconds.
  • Then run a macro by UI Vision.

The script that I learnt from @User9898, from this topic: No tab with id solution

But I keep having this No tab with id error. Not every time, but sometime when I need it to be run auto when I’m not around, it has this error.

Is there a way to fix this? I run this several times per day, both manual and auto, but I really need it to be auto running at 7 AM in my timezone.

What should I do?