Friday 21 April 2017

Protractor: Two drop down menus on the same page, can only successfully select element from one dropdown menu

I'm using Protractor to run an automated script, on one of the pages there are two drop down menus that are located below/above each other. The two of them seem identical only that they have different ng-model names etc. I can sucessfully select an element from one of the drop down menus but I can't for the other. It's kind of wrecking my head as to why one works and the other doesn't. Here is the code for the drop down menu where I can select an element

<select class="form-control ng-pristine ng-invalid ng-invalid-required" ng-model="user.sourceOfFunds" required="" ng-class="{submitted:invalid}">
                <option value="">Select</option>
                <option value="Savings">Deposit</option>
                <option value="Inherited">Current</option>
                <option value="Other">Savings</option>
                        </select>
element(by.model('user.sourceOfFunds')).sendKeys('Savings');

My other dropdown menu is as follows:

<select class="form-control ng-pristine ng-invalid ng-invalid-required" ng-model="user.investFigure" required="" ng-class="{submitted:invalid}">
                         <option value="">Select</option>
                         <option value="<20">Less than 20K</option>
                         <option value="20-50">20K-50K</option>
                         <option value="50-100">50K-100K</option>
                         </select>
element(by.model('user.investFigure')).sendKeys('Less than 20K');
or
element(by.model('user.investFigure')).sendKeys('20');

I get "element not found" when I try to select an item from the second drop down menu. I'm at a bit of a loss as to why this is happening



via Edmond

No comments:

Post a Comment