diff options
author | Saumit Dinesan <justsaumit@protonmail.com> | 2023-02-01 01:41:26 +0530 |
---|---|---|
committer | Saumit Dinesan <justsaumit@protonmail.com> | 2023-02-01 01:41:26 +0530 |
commit | ebb91e461604629b129502d821ba1dadeb18bbdb (patch) | |
tree | 838fe17c573484504dd086578defc4bd3cdc4ced | |
parent | 6ce7b3a5e4edfc2685468e4df31de6463bddcd6e (diff) |
readme - minor changes(rebase)
-rw-r--r-- | README.md | 15 | ||||
-rw-r--r-- | auto-login.py | 18 |
2 files changed, 13 insertions, 20 deletions
@@ -5,13 +5,11 @@ A small python script which allows you to automatically login to a captive porta ## Pre-Requisites: [Selenium Webdriver](https://www.selenium.dev/documentation/webdriver/) for Python (install using `pip install selenium` or `pip install -r requirements.txt`) [GNU pass](https://www.passwordstore.org/) for storing login-credentials (One can store their credentials in the script as plaintext aswell) -geckodriver for Firefox ([Download link](https://github.com/mozilla/geckodriver/releases)) -Add the location of the geckodriver executable to your system's PATH environment variable. -[Tutorial](https://www.learningaboutelectronics.com/Articles/How-to-install-geckodriver-Python-windows.php) - +geckodriver for Firefox in PATH (optional if not already included in selenium webdriver) +([Download link](https://github.com/mozilla/geckodriver/releases)) ## Brief Look: -[![auto-login](https://draconyan.xyz/pix/auto-login-clg.gif)](https://draconyan.xyz/pix/auto-login-clg.mp4) +[![auto-login](https://draconyan.xyz/media/al/auto-login.gif)](https://draconyan.xyz/media/al/auto-login.mp4) ## Usage: ``` @@ -61,7 +59,6 @@ With this it is the same except I get to automate it using [gnu pass](https://ww and that using XPath(XML Path) to find elements is really convenient. ## Future additions: -- [x] Update the script upon reaching college as the Xpath values would differ. (done in [382c298](https://github.com/justsaumit/auto-captive-portal-login/commit/e24805733d5689eba28770172cd1bd99dedf247d) & [e248057](https://github.com/justsaumit/auto-captive-portal-login/commit/e24805733d5689eba28770172cd1bd99dedf247d) ) -- [ ] Rewrite the script in Java -- [ ] Make the python-script platform independent -- [ ] Make a separate shellscript to log in via CLI using curl +Update the script upon reaching college as the Xpath values would differ. +Make the python-script platform independent +or just Make a separate shellscript to log in via CLI using curl. diff --git a/auto-login.py b/auto-login.py index 2475a1f..506d202 100644 --- a/auto-login.py +++ b/auto-login.py @@ -10,18 +10,14 @@ gateway=pipedps.communicate()[0].decode().strip() from selenium import webdriver from selenium.webdriver.common.by import By -options = webdriver.FirefoxOptions() -options.set_capability("acceptInsecureCerts", True) -options.set_capability("assume_untrusted_cert_issuer", True) - - -driver = webdriver.Firefox(options=options) +driver = webdriver.Firefox() driver.get("http://"+gateway) -driver.find_element(by=By.XPATH,value="//*[@id='cpusername']").send_keys(w_user) -driver.find_element(by=By.XPATH,value="//*[@id='cppassword']").send_keys(w_pass) -driver.find_element(by=By.XPATH,value="//*[@id='btnLogin']").click() -time.sleep(9) -if(driver.find_element(by=By.XPATH,value="//*[@id='btnLogout']").is_displayed()): + +driver.find_element(by=By.XPATH,value="//*[@id='tf1_userName']").send_keys(w_user) +driver.find_element(by=By.XPATH,value="//*[@id='tf1_password']").send_keys(w_pass) +driver.find_element(by=By.XPATH,value="/html/body/div[1]/div/div/div[2]/form/div/div[5]/button").click() +time.sleep(5) +if(driver.find_element(by=By.XPATH,value="//*[@id='lblLoggedinUser']").is_displayed()): print("Logged in successfully!") else: print("Login failed") |