diff options
author | Saumit Dinesan <justsaumit@protonmail.com> | 2023-02-01 01:51:52 +0530 |
---|---|---|
committer | Saumit Dinesan <justsaumit@protonmail.com> | 2023-02-01 01:51:52 +0530 |
commit | bae1f490fda38f2d523e597f5f6eabc6352136d6 (patch) | |
tree | 3f74d4d0c1f690129cbadb8a8e051ed7c29cd469 | |
parent | ebb91e461604629b129502d821ba1dadeb18bbdb (diff) |
Update the script upon reaching college+successful login button(rebase)
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | auto-login.py | 14 |
2 files changed, 9 insertions, 7 deletions
@@ -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") |