Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. import time
  2. from selenium import webdriver
  3. from selenium.webdriver.common.keys import Keys
  4. from selenium.common.exceptions import NoSuchElementException
  5.  
  6. driver = webdriver.Firefox() # Define browser as Firefox
  7. driver.set_window_size(600,600) # Set size of your browser window.
  8. driver.get("YOUR_ISP_URL") # Replace this with the url of your own ISP's login page.
  9. time.sleep(10) # Wait for 10 seconds after loading the ISP page.
  10.  
  11.  
  12. try:
  13. login_attempt = driver.find_element_by_xpath("//*['Please log on to use the Broadband Service.']") # It can be any Other Custom Message. So replace it. Example: 'Login to your profile.''
  14. username = driver.find_element_by_id("inputUsername") # It's the HTML Form Input ID of your Username. Replace it.
  15. password = driver.find_element_by_id("inputPassword") # It's the HTML Form Input ID of your Password. Replace it too.
  16. username.send_keys("YOUR_USERNAME_HERE") # Replace this with your own Username.
  17. password.send_keys("YOUR_PASSWORD_HERE") # Replace this with your own Password.
  18. login_attempt = driver.find_element_by_xpath("//*[@type='submit']")
  19. login_attempt.submit()
  20. assert "You are logged in successfully." in driver.page_source # Asserts that you have logged in successfully and prints a custom message.
  21. print("You're successfully logged in.")
  22. time.sleep(5)
  23. driver.close() # Closes the browser window.
  24.  
  25. except NoSuchElementException: # If you're already logged in, without showing an error, it shows you a custom message.
  26. print("Oh, you're already logged in.")
  27. time.sleep(5)
  28. driver.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement