Paste Search Dynamic
Recent pastes
from selenium webdriver chrome
  1. from selenium import webdriver #Import the webdriver to launch Chrome driver here
  2. from selenium.webdriver.chrome.options import Options #Import Options from Selenium to configure our driver
  3.  
  4. options = Options() #Declare options
  5. options.headless = true #True=the driver won't be launch and False it will be launch
  6. options.add_argument("--window-size=1000,1080") #Size of driver's window
  7. options.add_argument("--incognito") #If you add this argument, the driver will launch a private session
  8. DRIVER_PATH = "/Users/maximemora/Desktop/chromedriver" #Replace by the path of your driver's executable
  9. driver = webdriver.Chrome(options=options, executable_path=DRIVER_PATH) #Create and init with options your driver
  10. driver.get('https://github.com/login') #Get url with the driver
  11.  
  12. #Affichage de l'url
  13. if (driver.title == "Sign in to GitHub ยท GitHub"):
  14.     print("Page de connexion")
  15. else:
  16.     print("Erreur")
  17.  
  18. #Recuperation des elements du formulaire
  19. print("-- Recuperation des donnees")
  20. form_login = driver.find_element_by_id('login_field')
  21. form_password = driver.find_element_by_id('password')
  22. form_submit = driver.find_element_by_xpath("//input[@type='submit']")
  23. #
  24.  
  25. #Ajout des donnees
  26. print("-- Ajout des donnees")
  27. form_login.click()
  28. form_login.send_keys("email@github.com")
  29. form_password.click()
  30. form_password.send_keys("motdepasse")
  31. #
  32.  
  33. #Validation du formulaire
  34. print("-- Validtion du formulaire")
  35. form_submit.click()
  36. #
  37.  
  38. #Affichage de l'url
  39. if (driver.title == "GitHub"):
  40.     print("Connexion etablie")
  41. else:
  42.     print("Connexion non etablie")
  43.  
  44. driver.quit() #Close the driver at the end of the program
Parsed in 0.022 seconds