-
Notifications
You must be signed in to change notification settings - Fork 0
/
twitter.py
24 lines (16 loc) · 982 Bytes
/
twitter.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
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
class Twitter:
def __init__(self, username, password):
self.browser=webdriver.Chrome()
self.username = username
self.password = password
def singIn(self):
self.browser.get("https://twitter.com/login")
usernameInput = self.browser.find_element_by_xpath("//*[@id='react-root']/div/div/div[2]/main/div/div/div[2]/form/div/div[1]/label/div/div[2]/div/input")
passwordInput = self.browser.find_element_by_xpath("//*[@id='react-root']/div/div/div[2]/main/div/div/div[2]/form/div/div[2]/label/div/div[2]/div/input")
usernameInput.send_keys(self.username)
passwordInput.send_keys(self.password)
btnSubmit = self.browser.find_element_by_xpath("//*[@id='react-root']/div/div/div[2]/main/div/div/div[2]/form/div/div[3]/div/div")
btnSubmit.click()