My question actually is the same as this one login to yahoo email account using Python Selenium webdrive
But since Yahoo has changed its login form UI, the answer provided in the above link doesn't work to me. Instead I tried the below code.
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
browser = webdriver.Firefox()
browser.get('https://login.yahoo.com')
emailElem = browser.find_element_by_id('login-username')
emailElem.send_keys('thisismyemail@yahoo.com')
emailElem.submit()
passwordElem = WebDriverWait(browser, 10).until(
EC.presence_of_element_located((By.ID, "login-passwd"))
)
passwordElem.send_keys('thisismypassword')
passwordElem.submit()
wait = WebDriverWait(browser, 10)
wait.until(lambda browser: browser.current_url == "https://www.yahoo.com")
browser.get("https://mail.yahoo.com")
When I run the above code, it always gives me the password input page. I executed the code line by line, I think the second wait after password submission didn't work.
Need your advice how to change it for redirecting to the yahoo main page on successful login before navigating to the Yahoo mail box. Thank you!
Follow-up questions: @DebanjanB and @Nimish Bansal, Thanks a lot for your answers! I tried and both of your answers can work. I understand the key difference from my code is to change .submit() to .click(). But why? From the Selenium-Python document(http://selenium-python.readthedocs.io/navigating.html#filling-in-forms), both work in the same way for filling in forms. Any reference to elaborate the difference between .submit() and .click()? Thanks.