Niagara Kiosk Mode Auto-Login

by


Posted on


Niagara Kiosk Mode Auto-Login...

This KB shows you how to turn your Niagara station into a Kiosk mode with an auto-login feature. It uses a combination NW.js, Chromedriver, Selenium, and a small Python script. The main issue is when the pc restarts that it doesn't automatically log-in to the station. By the end of this article, you'll have a fully running touch screen panel with an auto-login mechanism. You could use it for a touch screen panel or a dashboard.


Download NW.js, Python, Chromedriver, and Selenium.

1. Download NW.js SDK Version - this is SDK version which includes Chromedriver. Unzip into a new folder. We'll come back to this in a bit. NW.js is an app runtime based on Chromium and node.js. You can write native apps in HTML and JavaScript with NW.js. It also lets you call Node.js modules directly from the DOM and enables a new way of writing native applications with all Web technologies.

2. Download Python - 3.6.3 for Windows 64bit version. Make sure you get the correct version for your OS. Follow the install instructions carefully. By the end of the installation, you should be able to open command prompt and type in python. Python is an interpreted high-level programming language for general-purpose programming.

3. To install Selenium open command prompt from the same folder you created in step 1 and type in pip install selenium. Selenium Python bindings provide a convenient API to access Selenium WebDrivers like Firefox, Ie, Chrome, Remote etc. We'll use this to automate the Niagara station web login.


4. Create a package.json file in the same folder you created in step 1. This is the NW.js configuration. Here is an example, modify as needed.


{
    "main": "http://localhost/ord...",
    "name": "nw-demo",
    "description": "demo app of node-webkit",
    "version": "0.1.0",
    "keywords": [ "demo", "node-webkit" ],
    "window": {
    "title": "node-webkit demo",
    "icon": "link.png",
    "toolbar": true,
    "frame": false,
    "fullscreen": true
    },
    "webkit": {
    "plugin": true
    }
}
                                    

5. Create a file called launch.py in the same folder as the NW.js files. Copy the script below, modify as needed. Obviously credentials are stored in this file and every precaution should be used to protect it. However, a colleague did recommend that you could save the credentials using the browser credential save mechanism, and then just the invoke the "keys.RETURN" without putting your username and password in.

 
import time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
chrome_options = Options()
chrome_options.add_argument("nwapp=nw.exe")

driver = webdriver.Chrome(executable_path='chromedriver.exe', chrome_options=chrome_options)

time.sleep(3) # Wait 3s to see the station page page. Increase time if needed so the station is properly loaded after pc restart.
search_box = driver.find_element_by_name('j_username')
search_box.send_keys('demoLogin')
search_box.submit()
time.sleep(3) # Wait 3s to see the result

search_box1 = driver.find_element_by_name('j_password')
search_box1.send_keys('DemoPassword123')
search_box1.send_keys(Keys.RETURN)  // submit wouldn't work here, hence using enter key instead
              


6. Basically thats all you need to do. With command prompt open, type in launch.py and watch it log in automatically. To finish off this mechanism, have the launch.py run when the PC restarts via a .bat file or something similar. I'll leave that up to you.

N4 Software

Maximize Your Graphics

Used by some of the largest companies in the world

back to knowledge base...