I want to use expect() to assert something in my e2e test, but expect() operates on Future's only. How can I get this to work:
expect(true).toBe(true);
The above expect() call works fine in unit tests, but expect() is a different beast in e2e tests. In my situation I need to verify that all radio buttons are not checked. Here's the code:
//first grab all radios in my DOM
element('.hhmInHousehold div > input[type="radio"]', 'member status').query(function(radios,doneFn){
//cycle through each radio to check if it is checked
angular.forEach(radios, function(radio, key)
{
if(radio.checked !== false) {
//in my perfect world this if check, then throw
//statement should just be: expect(radio.checked).toBe(false);
throw "expected radio checked to not be checked";
}
});
doneFn();
});
In the above, I am doing an inelegant if statement, then throwing an exception. Is there a better way to do this?
Thanks!
I don't know an easy way around using a future as the input to expect but you can do something like this to make sure all checkboxes are not selected:
expect(element('input:checked').count()).toBe(0);
In case you haven't seen it here is the documentation for the E2E API.
I managed to do the following to check if the element is hidden:
expect(element("#id_element").css("display")).toBe("none");
And to check if this element is visible:
expect(element("#id_element").css("display")).not().toBe("none");
I believe this is not the best way. But it is simple, and it worked for me.
Cheers!