summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaumit Dinesan <justsaumit@protonmail.com>2023-02-01 01:51:52 +0530
committerSaumit Dinesan <justsaumit@protonmail.com>2023-02-01 01:51:52 +0530
commitbae1f490fda38f2d523e597f5f6eabc6352136d6 (patch)
tree3f74d4d0c1f690129cbadb8a8e051ed7c29cd469
parentebb91e461604629b129502d821ba1dadeb18bbdb (diff)
Update the script upon reaching college+successful login button(rebase)
-rw-r--r--README.md2
-rw-r--r--auto-login.py14
2 files changed, 9 insertions, 7 deletions
diff --git a/README.md b/README.md
index c5fcfce..6abba56 100644
--- a/README.md
+++ b/README.md
@@ -59,6 +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:
-Update the script upon reaching college as the Xpath values would differ.
+~~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 506d202..39952a6 100644
--- a/auto-login.py
+++ b/auto-login.py
@@ -10,14 +10,16 @@ gateway=pipedps.communicate()[0].decode().strip()
from selenium import webdriver
from selenium.webdriver.common.by import By
-driver = webdriver.Firefox()
-driver.get("http://"+gateway)
+profile = webdriver.FirefoxProfile()
+profile.accept_untrusted_certs = True
-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()
+driver = webdriver.Firefox(firefox_profile=profile)
+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(5)
-if(driver.find_element(by=By.XPATH,value="//*[@id='lblLoggedinUser']").is_displayed()):
+if(driver.find_element(by=By.XPATH,value="//*[@id='btnLogout']").is_displayed()):
print("Logged in successfully!")
else:
print("Login failed")