from selenium import webdriver #Import the webdriver to launch Chrome driver here
from selenium.webdriver.chrome.options import Options #Import Options from Selenium to configure our driver
options = Options() #Declare options
options.headless = true #True=the driver won't be launch and False it will be launch
options.add_argument("--window-size=1000,1080") #Size of driver's window
options.add_argument("--incognito") #If you add this argument, the driver will launch a private session
DRIVER_PATH = "/Users/maximemora/Desktop/chromedriver" #Replace by the path of your driver's executable
driver = webdriver.Chrome(options=options, executable_path=DRIVER_PATH) #Create and init with options your driver
driver.get('https://github.com/login') #Get url with the driver
#Affichage de l'url
if (driver.title == "Sign in to GitHub ยท GitHub"):
print("Page de connexion")
else:
print("Erreur")
#Recuperation des elements du formulaire
print("-- Recuperation des donnees")
form_login = driver.find_element_by_id('login_field')
form_password = driver.find_element_by_id('password')
form_submit = driver.find_element_by_xpath("//input[@type='submit']")
#
#Ajout des donnees
print("-- Ajout des donnees")
form_login.click()
form_login.send_keys("email@github.com")
form_password.click()
form_password.send_keys("motdepasse")
#
#Validation du formulaire
print("-- Validtion du formulaire")
form_submit.click()
#
#Affichage de l'url
if (driver.title == "GitHub"):
print("Connexion etablie")
else:
print("Connexion non etablie")
driver.quit() #Close the driver at the end of the program