2015-06-02 20 views
2

我目前試圖測試下面的代碼PICE:ASYC錯誤

<footer class="footer"> 
    <div class="container"> 
     <div class="row"> 
      <form subscribe-directive="" ng-controller="SubscribeController" class="form col-xs-12 col-sm-8 col-md-6 col-lg-4 ng-scope ng-dirty ng-valid ng-valid-email"> 
       <h3 class="footer__title text-uppercase margin-bottom-25">Sign up!</h3> 
       <div class="row"> 
        <div class="col-sm-8 col-xs-7"> 
         <input type="email" class="form-control ng-touched ng-dirty ng-valid ng-valid-email" ng-disabled="working || subscription.done" placeholder="Email Address" ng-model="subscription.email"> </div> 
        <div class="col-sm-4 col-xs-5"> 
         <button ng-click="submit(subscription.email)" ng-disabled="working || !subscription.email || subscription.done" ng-class="{'working': working}" class="btn btn--inverse btn-red form-control" type="submit" disabled="disabled"> <span ng-bind-html="submitBtn" class="ng-binding">SUBSCRIBE</span> </button> 
        </div> 
       </div> 
       <p ng-show="callback_message" class="msg ng-binding ng-hide" ng-bind-html="callback_message"></p> 
      </form> 
      <nav class="col-xs-12 col-md-6 col-lg-offset-2"> 
       <ul class="nav navbar-nav navbar-right margin-bottom-25"> 
        <li><a href="/press">Press</a> 
        </li> 
        <li><a href="/news">News</a> 
        </li> 
        <li><a href="/contact">Contact Us</a> 
        </li> 
        <li><a target="_blank" href="//test.com/en">Test Project</a> 
        </li> 
       </ul> 
       <ul class="nav navbar-nav navbar-right"> 
        <li class="footer__social-icon"> <a target="_blank" href="https://www.facebook.com/"><i class="fa fa-facebook"></i></a> </li> 
        <li class="footer__social-icon"> <a target="_blank" href="https://twitter.com/"><i class="fa fa-twitter"></i></a> </li> 
        <li class="footer__social-icon"> <a target="_blank" href="https://www.youtube.com/user/"><i class="fa fa-youtube"></i></a> </li> 
       </ul> 
      </nav> 
     </div> 
     <div class="row"> 
      <div class="col-xs-12 col-sm-6 copy"> <a href="/privacy">Privacy Policy</a> 
       <br> Copyright &copy; Test-inc. All Rights Reserved. </div> 
      <div class="col-xs-12 col-sm-6 text-right copy"> 
       <br> Microsoft Ventures. Supported by Microsoft Ventures London Accelerator </div> 
     </div> 
    </div> 
</footer> 

但是,當我執行以下操作:

it('User should see a message that he has already been added to the campaing when entering the same email twice', function() { 
     browser.executeScript("window.scrollBy(0,10000)"); 
     basePage.email.sendKeys('[email protected]'); 
     basePage.subscribe.click().then(function() { 
      browser.sleep(7000); 
      basePage.confirmMessage('Contact already added to target campaign'); 
    }); 

在我的BasePage我有:

//this.email = element(by.model('subscription.email')); 
this.email = element(by.xpath('/html/body/footer/div/div[1]/form/div/div[1]/input')); 
    this.waitlistBtn = element.all(by.binding('submitBtn')); 
    this.subscribe = element(by.buttonText('SUBSCRIBE')); 

我不斷收到follwing錯誤(我運行它反對BrowserStack):

Failures: 
1) New Landing page module verification --> User should be correctly added to the update list 
    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. 
     at Timer.listOnTimeout (timers.js:110:15) 

這裏是我的我的配置的一部分:

{ 
      name: testName, 
      browserName: 'IE', 
      browser_version: '11.0', 
      os: 'Windows', 
      os_version: '8.1', 
      resolution: '2048x1536', 
      'browserstack.user': browserstackUser, 
      'browserstack.key': browserstackKey, 
      'browserstack.debug': 'true', 
      'browserstack.selenium_version': '2.45.0', 
      'browserstack.ie.driver': '2.44', 
      ignoreProtectedModeSettings: true 
     } 
    onPrepare: function() { 
     jasmine.getEnv().addReporter(reporter); 

     browser.driver.manage().window().maximize(); 
     global.dvr = browser.driver; //variable to call selenium directly 
     global.isAngularSite = function (flag) { 
      browser.ignoreSynchronization = !flag; //This setup is to configure when testing non-angular pages 
     }; 
     //browser.manage().timeouts().pageLoadTimeout(90000); 
     browser.manage().timeouts().implicitlyWait(100000); 

    } 

我必須澄清的是它不與其他測試IE發生,它只是這部分該圖標位於頁面的頁腳發生。

你能幫忙嗎?你有什麼建議嗎?或者你能看到我做錯了什麼?

Thanks.-

回答

2

因爲我有很多的問題,以避免異步,我已經決定,對於這種特殊情況,以避免IE!我做了以下幾點:

it('User should see a message that he has already been added to the campaing when entering the same email twice', function() { 

    browser.getCapabilities().then(function (capabilities) { 
     browser = capabilities.caps_.browserName; 
     platform = capabilities.caps_.platform; 
    }).then(function() { 
     console.log('Browser:', browser, 'on platform', platform); 
     if (browser == 'internet explorer') { 
      console.log('IE Was avoided for this test.'); 
     } else { 
      basePage.email.sendKeys('[email protected]'); 
      console.log('Mande el mail'); 
      basePage.subscribe.click().then(function() { 
       basePage.confirmMessage('Contact already added to target campaign'); 
      }); 
     } 
    }); 

}); 

請讀者如果有更好的解決方案,請發佈。

+1

那麼,如果您要避免在IE上運行測試,請嘗試通過'multiCapabilities'設置中的'specs'或'suites'對其進行配置。您可以使用'exclude'來排除針對特定功能執行的特定測試。 – alecxe

+0

我只是想爲這個特殊測試做這個測試,也不是爲了所有的測試。我的意思是,我不知道爲什麼測試,IE不想工作,但是對於類似的情況, 無論如何,我不知道如何排除工程,所以我會調查.. –

+0

我想你提到這個:https://github.com/angular/protractor/issues/1230 而這是爲排除整個規範...正確? –