Reputation: 1141
I have a block of code that I am trying to confirm the "name" value on, but it is returning an extremely unexpected value, and I hoping that someone can point me to where I went wrong.
The html that I am searching over is below:
<div class="col" ng-repeat="bank in firstBanks">
<div style="font-size: 2em; ">
<label class="bank_radio">
<input type="radio" ng-model="bankConnection.bank" ng-value="bank" class="ng-pristine ng-valid" name="00D" value="[object Object]">
<img ng-src="img/banks/bofa.png" src="img/banks/bofa.png">
</label>
</div>
</div>
I am attempting to grab the value found in name="00D" so I have the block of code below as an expect() to make sure that I am grabbing the right element before I move onto my next steps.
expect(element.all(by.repeater('bank in firstBanks')).get(0).element(by.css('[ng-value="bank"]')).getAttribute('name')).toEqual('00D');
For some reason it is constantly returning "011" with the error:
Message:
Expected '011' to equal '00D'.
This is extremely confusing to me as I have nowhere on my page with the text "011" at all. Any help would be greatly appreciated, I am new to Protractor and still getting a handle on the syntax.
EDIT:
Updated my snippet to be simplified per "alecxe" response. The error that is being returned now is the following "[ '011', '013', '015', '019', '01B' ] to equal '00D'". Does anyone have any idea where these values are being generated from? Because I do not have any of those in my page.
The repeater that I have setup does have 5 instances, and that matches the number that are being returned in that error message, but I feel like this are just being randomly set.
Upvotes: 1
Views: 88
Reputation: 473833
You can simplify the test by using by.model()
:
expect(element(by.model('bankConnection.bank')).getAttribute('name')).toEqual('00D');
or:
expect(element.all(by.model('bankConnection.bank')).get(0).getAttribute('name')).toEqual('00D');
Upvotes: 2