0
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time

PATH = 'C:\Program Files (x86)\chromedriver.exe'
driver = webdriver.Chrome(PATH)

driver.get('https://outlook.office.com/mail/')

driver.implicitly_wait(7)
login = driver.find_element_by_name("loginfmt")
login.send_keys("emailhere")
login.send_keys(Keys.RETURN)

driver.implicitly_wait(5)

password = driver.find_element_by_name("passwd")
password.send_keys("passwordhere")
password.send_keys(Keys.RETURN)

It perfectly inputs the email and takes me to the password input screen, but at that point, it does not send the keys for the password. Any ideas on what is wrong with my code?

  • I'm not exactly sure what may be causing your problem, but this question might help you: [How to wait until an element is present in Selenium?](https://stackoverflow.com/questions/20903231/how-to-wait-until-an-element-is-present-in-selenium) – Dante Culaciati Sep 02 '21 at 02:27

2 Answers2

0

explicit wait is needed here. refer wait, so code will be like

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

password = WebDriverWait(driver, 20).until(
        EC.element_to_be_clickable((By.NAME, "passwd"))
    )

password.send_keys("passwordhere")

additional reference at: documentation

simpleApp
  • 2,885
  • 2
  • 10
  • 19
0

I have tried with below code, which is maximizing the screen, and then using Name attribute with Explicit waits, it is working fine.

driver = webdriver.Chrome(driver_path)
driver.maximize_window()
driver.get('https://outlook.office.com/mail/')
wait = WebDriverWait(driver, 20)

login_btn = wait.until(EC.element_to_be_clickable((By.NAME, "loginfmt")))
login_btn.send_keys("some name")

wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input[value='Next']"))).click()

password_btn = wait.until(EC.element_to_be_clickable((By.NAME, "passwd")))
password_btn.send_keys("Your password")

Imports :

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
cruisepandey
  • 28,520
  • 6
  • 20
  • 38