Python: How to trick Selenium(undetected_chromedriver) window to think it's focused?

40 Views Asked by At

I'm currently trying to build a python app that automatically sends the prompt and receive the latest div's text from ChatGPT. The problem is that whenever the chromedriver window is not visible, the code would not work. After some research, I've found out that the ChatGPT website has it's own function to check if the window is on focus or not. document.hasFocus has it's own native function How can I make the chatgpt website to think that the user is on focus on the chromedriver window?

I've already tried using headless mode, but no good. It will still fail to find the correct element. Also moved the chromedriver window to virtual desktop, but no good. It will intervene each other, making some weird, cutted off responses from the website.

0

There are 0 best solutions below