random_error
random_error

Reputation: 375

getting and using an attribute in protractor tests

this question is probably pretty basic, but I don't have the right feel for angularjs and protractor yet, as I'm new to using this. This might therefore be an XY problem kind of question. If that is the case, I'd be happy to know about this, and get a hint what to look for instead.

Actual Question

Say I want to test a slider, and wish to set the the slider-knob to the middle of that slider, to then compare the value the slider has to an expected value.

The slider might have a width that I do not know beforehand, so I'm wondering what the correct way is to get and use such an unknown value in a protractor test.

Do I wrap the it(..) statement into a promise that gets the desired value (for example via getAttribute()? or is there are better way to go on about this?

Upvotes: 1

Views: 36

Answers (1)

random_error
random_error

Reputation: 375

I've solved it by just using promise chaining to work with the values. I don't like that I have to do this for every spec where I need the values, but it seems nice enough otherwise.

Example:

it('should test some stuff', () => {
    page.someElement.getAttribute('someAttribute').then(someAttribute => {
      // ... use someAttribute here ...
    });
});

Upvotes: 1

Related Questions