Check to verify that login failed

Consider example of logging in with invalid password to gmail. It gives following error message on the response page:

The email or password you entered is incorrect.

Here are few lines in the HTTP response, related to the error message:

The email or password you entered is incorrect.

<a href=“https://support.google.com/accounts/bin/answer.py?answer=27444&hl=en&ctx=ch_ServiceLoginAuth&p=mail

target="_blank" class=“help-link”>?

I tried to check the error message with following check:

.check(regex(“The email or password you entered is incorrect.”))

The check is failing. I tried with some more checks as follows, but they are failing too:

.check(xpath("//span[text()=‘The email or password you entered is incorrect.’]"))

.check(xpath("//span[@id=‘errormsg_0_Passwd’]"))

.check(css("#errormsg_0_Passwd"))

.check(css(".error-msg"))

Could you please help me understand why above check statements are failing?

xpath will only work if the HTTP response body is valid XML (like in SOAP messages, or XML-RPC, or even XHTML, but not regular HTML).
css will work with HTML, so if won’t work if what you’re looking for is actually is some javascript instead of being part of the HTML DOM.

Have you tried using regex?

Yes, first I tried with regex. Here is the regex check, which is failing too:
.check(regex(“The email or password you entered is incorrect.”))

It should be working. Are you sure that this is the actual HTTP response that you get?
For example, are you sure that you don’t miss some request headers?

Try lowering the logging level in logback.conf in order to check out the response bodies.