Sid
Sid

Reputation: 645

How to get webservice response in a protractor test

I'm using protractor to automate my application, I have a weird toggle button where it does not have button text in the html source instead it is returning a web service response, I'm new to web service concepts.

Toggle button source code:

enter image description here

<div class="assessment-config-switch assessment-switch">
<input id="fire_{"specialtyId":3,"activeTf":true,"specialtyName":"GI","quickCode":"GI","amaSpecialtyCode":null,"licenseKindId":null,"type":null,"itemId":3,"itemType":null,"itemName":"GI"}" class="showhideswitch-checkbox ng-untouched ng-valid ng-dirty ng-valid-parse" type="checkbox" ng-click="assessmentConfigCtrl.saveToggleOption(assessmentConfigCtrl.fireOptions)" ng-model="assessmentConfigCtrl.fireOptions.configFlagTf">
<label class="showhideswitch-label" for="fire_{"specialtyId":3,"activeTf":true,"specialtyName":"GI","quickCode":"GI","amaSpecialtyCode":null,"licenseKindId":null,"type":null,"itemId":3,"itemType":null,"itemName":"GI"}">
<span class="showhideswitch-inner"></span>
</label>
</div>
</div>

Whenever I click the toggle button, I'm getting a web service response:

enter image description here When i click on Show button the response would be as below

[
  {
    "configToggleMapId": 1086,
    "configId": 20,
    "organizationId": 76,
    "specialtyId": 3,
    "configFlagTf": true,
    "configValue": null,
    "config_Name": "Fire_Risk",
    "isUpdated": true
  }
]

When i click on Hide the response would be

[
  {
    "configToggleMapId": 1086,
    "configId": 20,
    "organizationId": 76,
    "specialtyId": 3,
    "configFlagTf": false,
    "configValue": null,
    "config_Name": "Fire_Risk",
    "isUpdated": true
  }
]

I need to get the value of "configFlagTf", based on the return value I will do my operations.

Upvotes: 1

Views: 178

Answers (1)

I agree with alecxe. With Protractor you can only get information that users would have. As a user, you can see the state of the toggle button by the color.

You should be able to get the color of the button by writing something like myButton.getCssValue('color').

The problem is that the test will give false results if you change the color of your button.

Upvotes: 1

Related Questions