Hello Nauman,
I would recommend referring to the
Modern Browser Automation course at BP University which mentions the best practice for dealing with modern browsers.
Also rather than automating Gmail on the UI level, you can explore other assets on Digital Exchange that can work using API for email operations on Gmail.
That will be faster, more reliable, and more efficient than UI automation.
------------------------------
If I was of assistance, please vote for it to be the "Best Answer".
Thanks & Regards,
Tejaskumar Darji
Sr. Consultant-Technical Lead
------------------------------