from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
browser = webdriver.Chrome()
browser.get('https://www.instragram.com')
wait = WebDriverWait(browser, 10)
login_elem = browser.find_element_by_xpath(
'//*[@id="react-root"]/section/main/article/div[2]/div[2]/p/a')
second_page_flag = wait.until(EC.presence_of_element_located(
(By.CLASS_NAME, "KPnG0"))) # util login page appear
user = browser.find_element_by_name("username")
passw = browser.find_element_by_name('password')
ActionChains(browser)
.move_to_element(user).click()
.send_keys('test')
.move_to_element(passw).click()
.send_keys('test')
.perform()
login_button_ = browser.find_element_by_xpath(
"//form[@class='HmktE']/div[3]/button")
login_button_.click()