Reputation:
I am trying to login to Bing using selenium. My code enters in the correct email, presses ENTER, and then types a password. Then, it is supposed to press ENTER again. But once it types in the password, it doesn't continue to the next page. Nothing pops up in terminal. It doesn't say "Incorrect login." It just stays on the login page with the password typed into the input box. Heres the code:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
browser = webdriver.Chrome('/Users/grayson1/Downloads/chromedriver')
browser.get('https://login.live.com/login.srf?wa=wsignin1.0&rpsnv=13&ct=1592312166&rver=6.7.6631.0&wp=MBI_SSL&wreply=https%3a%2f%2fwww.bing.com%2fsecure%2fPassport.aspx%3frequrl%3dhttps%253a%252f%252fwww.bing.com%252f%253fwlexpsignin%253d1%26sig%3d129CDB0DE83D6A123FB7D5E7E9ED6B4B&lc=1033&id=264960&CSRFToken=5a18094e-a0f1-4ad1-afb6-a03aac0295fc&aadredir=1')
username = browser.find_element_by_id('i0116')
username.send_keys("EMAIl")
username.send_keys(Keys.ENTER)
password = browser.find_element_by_id('i0118')
password.send_keys('PASSWORD')
password.send_keys(Keys.ENTER)
Upvotes: 0
Views: 455
Reputation: 106
Try to navigate to that button first:-
WebElement signInbtn = driver.findElement(By.id("idSIButton9"));
signInbtn.click();
or
signInbtn.submit()
If this doesn't work try Actions class
WebElement signInbtn = driver.findElement(By.id("idSIButton9"));
Actions builder = new Actions(driver);
Action seriesOfActions = builder
.moveToElement(signInbtn)
.click().perform();
Upvotes: 0
Reputation: 3503
Define password
as below, then send keys and Enter:
password = WebDriverWait(browser, 5).until(EC.element_to_be_clickable((By.ID, 'i0118')))
password.send_keys('PASSWORD'+Keys.ENTER)
Add these imports for WebDriverWait
:
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
For consistency, you could define username
the same way.
Upvotes: 1
Reputation: 978
Can you do this process manually as typing credentials and Click enter if you are not you cant do it as automation too
Upvotes: 0