Environment: node.js, Windows 10, cmd
Npm: Selenium-webdriver (chromedriver), ... Express.js, node-schedule, node-windows
I have seen multiple similar posts on this topic here, but none of them were able to help me. It also took me a little time to understand my own situation.
I am spawning a Selenium automated chrome browser from an Express.js server terminal. I am using the node-schedule
package to schedule the start time of the automated chrome. It is fine when I have focus on the server cmd terminal - Chrome gets focus. However, when I don't have focus on the server terminal, then the automated chrome is always in background. It is not practical for me to always have the server terminal in focus 24/7.
Only cmd terminal supports the above mentioned behavior. Git bash and power shell are not helpful at all.
I have tried all the generic suggested solutions mentioned below with no success:
- chrome.executeScript(windows.focus())
- minimize and maximize, or resize the chrome window 4 times
- I read the chromedriver reference and tried sending multiple optional parameters to the driver with no success
One notable advice I saw stated that Selenium has no control over switching focus between window processes. That SO solution advised on using a Java based program that helps with bringing focus to processes as the OP of that SO thread was using Selenium - Java. Unfortunately, I did not save the URL and now I cannot find that Stack Overflow thread.
I am looking for any javascript based program that will help me bring either the chrome window or the server terminal to foreground.
Thank you for your time and advices