I'm new to Selenium /Python, I have Login validation. when user try to login, if password is Invalid or expired it will display 2 error message with different location. data is coming from excel with for loop. (Data driven framework).
If login password is expired it is working fine. the its moving to next, if password is invalid still its checking password expired condition only and exist the loop and give 'error'. It's not going through elif
or else
.
print("Login Pass")
else:
time.sleep(5)
try:
if (self.driver.find_element_by_xpath(
self.lp.textbox_ConfirmPassword_xpath).is_displayed() == True) \
or (self.lp.verifyInvalidPasswordIsDisplay() == "Invalid username or password"):
if self.driver.find_element_by_xpath(self.lp.textbox_ConfirmPassword_xpath).is_displayed():
self.driver.find_element_by_xpath(self.lp.textbox_ConfirmPassword_xpath).click()
print("expired")
XLUtils.writeData(self.path, 'Sheet2', r, 6, 'Expired password')
elif self.lp.verifyInvalidPasswordIsDisplay() == "Invalid username or password":
print("invalid")
XLUtils.writeData(self.path, 'Sheet2', r, 3, 'Invalid username or password')
else:
XLUtils.writeData(self.path, 'Sheet2', r, 4, 'Error')
else:
print("error")
except NoSuchElementException:
XLUtils.writeData(self.path, 'Sheet2', r, 4, 'Error')
print(self.user)
print("login fail")
self.driver.close()
Aucun commentaire:
Enregistrer un commentaire