Somehow send_keys enters repeat password or string other than mentioned password leading login failure.
Tried adding explicit wait(), driver.clear() but does not work.
Here is a sample code in Python -
Approach 1 -
driver = webdriver.chrome(executable path)
driver.maximize__window()
driver.get(address)
password = "xyz"
field1 = wait.until(EC.presence_of_element_located(By.XPATH, <xpath of the password field>)
actionChains.move_to_element(field1).click()
actionChains.move_to_element(field1).send_keys(password).perform()
driver.find_element(By.ID, "Login-button").click()
Here instead of "xyz" probably "xyzxyzxyzx" string gets added to the password field(cannot decode as password gets masked).
Please suggest.
Approach 2 -
Also, another try with below code somehow concatenates username to the password while entering password.
username = driver.find_element(By.ID,"USERNAME").click()
actionChains.send_keys("test")
password = driver.find_element(By.ID,"PASSWORD").click()
actionChains.send_keys("xyz")
actionChains.perform()
This snippet results into -
Username as "test"
Password as "testxyz"
Expected output is:
Username as "test"
Password as "xyz"
CodePudding user response:
Sometimes it auto fills the last input. I get around it by just adding "Keys.BACK_SPACE*20" into the send keys brackets
.send_keys(Keys.BACK_SPACE*20, "xyz")
you will also need to import the Keys library:
from selenium.webdriver.common.keys import Keys
CodePudding user response:
Some assumptions that come to the top of my mind are some default values may have been populated already in the password field. This link may be helpful if that's the scenario. I'm not sure if that's the same thing driver.clear() does.
Also if there's a show password option that can be utilised to debug the issue. also other options for those can be gettext from the text box also can be helpful.