A small python script which allows you to automatically login to a captive portal with Selenium using XPath values.
- Selenium Webdriver for Python (install using
pip install selenium
orpip install -r requirements.txt
) - GNU pass for storing login-credentials (One can store their credentials in the script as plaintext as well)
- geckodriver for Firefox (Download link)
- Add the location of the geckodriver executable to your system's PATH environment variable. Tutorial
Previous looks:
$ git clone https://github.com/justsaumit/auto-captive-portal-login
$ cd auto-captive-portal-login/
If not using pass, edit autologin.py. Replace the values of w_user and w_pass When done Save and exit.
$ (text editor/IDE of choice) autologin.py
Replace "/path/to/" to the path of the python script(auto-login.py) When done Save and exit.
$ (text editor/IDE of choice) autologin
Make the 'auto-login' shellscript executable:
$ chmod +x auto-login
Now whenever you wish to login, use ./auto-login
.
If you want to add the script to your PATH: For system-wide
$ sudo cp auto-login /usr/local/bin
or For individual user
$ cp auto-login ~/.local/bin
And execute it from anywhere as:
$ auto-login
I originally wished to create a shell script to log into my College wifi-portal just using the terminal (Since I don't use a full-fledged desktop environment that would notify me to log in to a captive-portal).
I later set up this makeshift script
which just finds out the gateway IP and uses st's -e flag that allows st to open the captive-portal in a webbrowser on a new temporary terminal window.
The issue was I still had to type in my login credentials everytime :/
With this, it is the same except I get to automate it using gnu pass (my choice of a simple, secure and encrypted password manager)
and that using XPath(XML Path) to find elements is pretty convenient.