The easiest way, I guess:
## in your LoginPage class
error_msg = {'no credentials': text1, 'wrong password': text2} ## and so on.
def assert_login_error_msg(message, error_type):
assert message == self.error_msg[error_type], 'Wrong error message text for %s' % error_type
Then, after you call message = login_page.login_without_credentials()
:
login_page.assert_login_error_msg(message, 'no credentials')
UPD: You told that it's not easy to you to make right assertions. I think you must know if values you're going to enter are valid, so this shouldn'be a problem to chose right error message text.
UPD2: BTW, I'd suggest you to make a login method with (login, password, valid=True)
args, and, for this case, make the if else section at the end:
if not valid:
tooltip_message = WebDriverWait(self.driver, 10).until(lambda s: s.find_element_by_css_selector(self.tool_tip).text)
return tooltip_message
else:
return ## Or return some page class, where you should get after login