Prevent elements not being properly loaded in Selenium

Question:

I have this whatsapp bot and I need to send messages frequently while the user does other work, so the program opens chrome and then the user overlays it with another window "chrome window, file explorer or whatever", the problem is that on windows it works just fine, but on macOS, if you don’t focus on the whatsapp window, the program execute wrong commands like not seeing an element. Does anybody know a solution for this?

enter image description here

Asked By: Omar Yacop

||

Answers:

I’m not sure, but try running the Selenium script in headless mode. This can resolve your issue.

Answered By: Prophet