-
Notifications
You must be signed in to change notification settings - Fork 1
/
login_bot.py
31 lines (31 loc) · 1004 Bytes
/
login_bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import time
#input your username
username=""
#input your password
password=""
#source website
url="https://example.com"
#set your browser
driver=webdriver.Chrome()
#reach url data
driver.get(url)
#a little time for website fully load
time.sleep(2)
#find username input form path example
user=driver.find_element(By.XPATH,"/html/body/div[1]/div/div/div/div[1]/div/div[4]/div/div/div/div[1]/div[1]/input")
#send matching username
user.send_keys(username)
time.sleep(1)
#find password input form path example
pssw=driver.find_element(By.XPATH,"/html/body/div[1]/div/div/div/div[1]/div/div[4]/div/div/div/div[1]/div[2]/input")
#send matching password
pssw.send_keys(password)
time.sleep(1)
#find login button path exapmle
btn=driver.find_element(By.XPATH,"/html/body/div[1]/div/div/div/div[1]/div/div[4]/div/div/div/div[4]/button").click()
time.sleep(5)
#close the page
driver.close()