0
votes

When i check if the element is present the code works fine, if i check for element not present getting a Jasmine timeout.

var fee = $$('[ng-if="paymentDetails.responseObject[0].fee_amount > 0"]');
expect(fee.isPresent()).toBe(false);

Error message-

Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.

Stack: Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. Stack: at ontimeout (timers.js:386:14) at tryOnTimeout (timers.js:250:5) at Timer.listOnTimeout (timers.js:214:5)

On Config.js file i ahve set the jasmine timeout for 60secs

exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
multiCapabilities: [
    {
        browserName: 'chrome',
        shardTestFiles: true,
        maxInstances: 1,
        chromeOptions: {
            args: [
                '--disable-infobars',
                '--disable-extensions',
                'verbose',
                'log-path=./reports/chromedriver.log'
            ],
            prefs: {
                'profile.password_manager_enabled': false,
                'credentials_enable_service': false,
                'password_manager_enabled': false
            }
        }
    },
    {
        browserName: 'internet explorer',
        platform: 'ANY',
        version: '11'
     }
     ],
     framework: 'jasmine2',
      suites: {
      em2_login: ['e2e/tests/login/login.spec.js']
      } 
      useAllAngular2AppRoots: 'true',
      allScriptsTimeout: 60000,
      getPageTimeout: 60000,

      jasmineNodeOpts: {
      showColors: true,
      displayStacktrace: true,
      displaySpecDuration: true,
      defaultTimeoutInterval: 60000,
      disableChecks: true
      },
      params: {
      siteUrl: ''
       },
      onPrepare: function () {

      jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000;
      },
      },

I did tried by inserting browser.sleep(5000) and browser.waitforAngular() still getting timeouts.

Here is the HTML code for element with present state-

<tbody>
<!-- ngRepeat: lineItem in paymentDetails.responseObject[0].schedules[0].schedule_line_items track by $index -->
<tr class="ng-scope" ng-repeat="lineItem in paymentDetails.responseObject[0].schedules[0].schedule_line_items track by $index">
<td class="ng-binding">Jul 27, 2017</td>
<td>
<td class="ng-binding">$45.00</td>
<!-- ngIf: paymentDetails.responseObject[0].fee_amount > 0 -->
<td class="ng-binding ng-scope" ng-if="paymentDetails.responseObject[0].fee_amount > 0">$0.90</td>
<!-- end ngIf: paymentDetails.responseObject[0].fee_amount > 0 -->
<td>
<td class="" ng-switch="" on="lineItem.statusString" ng-show="lineItem.statusString" style="">
<td class="ng-binding ng-hide" ng-show="!lineItem.statusString" ng-bind-html="receiptTemplate.ready" style="">Ready</td>
<td class="ng-binding" ng-show="lineItem.authorizationString" ng-bind-html="lineItem.authorizationString" style="">53433 Bogus Gateway: Forced success</td>
<td class="ng-hide" ng-show="!lineItem.authorizationString" style=""/>
<td>
</tr>

Can anyone help me on this please?

1
Can you post full conf.js file please. Thanks! - demouser123
Have posted the complete conf.js file. - Smitha

1 Answers

0
votes

This code worked for me.

var fee = $$('[ng-if="paymentDetails.responseObject[0].fee_amount > 0"]').get(0);
expect(fee.isPresent()).toBe(false);