I'm running OS X 10.11, and I have created a web scraper using Python and Selenium. The scraper uses Firefox as the browser to collect data.  
The Firefox window must remain active at all critical steps, for the scraper to work.
When I leave the computer with Firefox as the active window, when I return I often find that the active window focus has changed to something else. Some process is stealing the window focus.
Is there a way that I can programatically tell the OS to activate the Firefox window? If so, I can tell the script to do that before every critical action in the script.
Preferably, this is something that I would like to achieve using Python. But launching a secondary AppleScript to do this specific task may also be a solution.
Note: Atm, I'm not looking at rewriting my script to use a headless browser – just to make it work by forcing active window.
tell application "Firefox" to activate
is the way to do it in AppleScript
Python: Activate window in OS X