I'm trying to write a test in Protractor, without highly coupling my test to specific markup of the page.
For example, given a typical log in page I'd want to test that if incorrect credentials are provided, an error message appears.
The way that my markup would display that error is:
<div class="alert alert-danger">
<ul>
<li>Invalid username or password.</li>
</ul>
</div>
This unordered list may contain other errors, too - so I don't want to make an assertion on the list element itself. In any case, I may decide to move away from displaying the error as a list, and may want to show it in some other way.
All I want is to be able to assert that the page contains: Invalid username or password.
I'd like to be able to do something like:
expect(page.getContents()).to.contain('Invalid username or password.');
But of course this doesn't work.
Are there any methods available in Protractor that can allow me to do this?
Aucun commentaire:
Enregistrer un commentaire