2017-04-10 9 views
0

分度器を使用してエンドツーエンドのテストを行います。私はSelenium WebDriverを使用しません.I charmブラウザに直接接続しました。私がテストを起動すると2つのエラーは、最初の1 occurred.the:分度器:ドームにリピータ要素が表示されるのを待つことはありません

conFusion App E2E Testing menu 0 item should show the number of comments as Message: Expected 0 to equal 5. Stack: Error: Failed expectation

秒1:

私はJSONサーバ使用

conFusion App E2E Testing menu 0 item should show the first comment author as Message: Failed: No element found using locator: by.model("FiltText") Stack:

は私のアンギュラアプリケーションでJSONデータにアクセスするためのREST APIを果たします5つのコメントとコメントを並べ替えるためのフィルタがあります。 また、私はgulpを使ってAngularアプリケーションを提供しました。私がターミナルの詰め物の時計を入力すると、物事はすべてうまくいった。しかし、分度器は失敗した。

要素がDOMに表示されるまで分度器を待機させるにはどうすればよいですか?

対応分度器構成コードは次のとおりです。

exports.config = { 
allScriptsTimeout:11000, 

    specs: [ 
    'e2e/*.js' 
    ], 
    capabilities: { 
    'browserName': 'chrome' 
    }, 

    baseUrl: 'http://localhost:3001/', 

    framework: 'jasmine', 
    directConnect: true, 

    jasmineNodeOpts: { 
    showColors: true, 
    defaultTimeoutInterval: 30000 
    } 
}; 
E2Eテストが含まれている

scenarios.jsコード

describe('menu 0 item', function() { 
    beforeEach(function() { 

    browser.get('index.html#/menu/0'); 


    }); 

    it('should have a name', function() { 
    var name = element(by.binding('dish.name')); 
    expect(name.getText()). 
    toEqual('Uthapizza Hot $4.99'); 
}); 

it('should show the number of comments as', function() { 

     expect(element.all(by.repeater('comment in dish.comments')) 
     .count()).toEqual(5); 


    }); 

    it('should show the first comment author as', function() { 
     element(by.model('FiltText')).sendKeys('author'); 

    expect(element.all(by.repeater('comment in dish.comments')) 
     .count()).toEqual(5); 

    var author = element.all(by.repeater('comment in dish.comments')) 
       .first().element(by.binding('comment.author')); 

    expect(author.getText()).toContain('25 Cent'); 

}); 
}); 

私がテストするHTMLページの部分コード:

<h4> Customer Comments &nbsp; 
       <span style="font-size:15px;">sorted by:<input type="text" ng-model="FiltText"></span></h4><blockquote ng-repeat="commet in dish.comments |orderBy:FiltText"> 
     <h5>{{commet.rating}} Stars</h5> 
     <h5>{{commet.comment}}</h5> 
     <footer>{{commet.author}}, <span>{{commet.date|date}}</span>. </footer> 

      </blockquote> 

答えて

0

waitinにはprotractor.ExpectedConditions.visibilityOfまたはpresenceOf()メソッドを使用します。 UIに表示されるか、またはDOMに表示されるまでg。以下のコードに従ってください:

var EC=protractor.ExpectedConditions; 
var targetEle=element(locator); 

browser.wait(EC.visibilityOf(targetEle),10000,'NOT VISIBLE'); //wait until 
//ele visible 
browser.wait(EC.presenceOf(targetEle),10000,'NOT PRESENT');//wait until 
//present in dom 
+0

は、Selenium WebDriverが提供するExpectedConditionsですか?私はSelenium WebDriverを使用していないためです。私はチャームブラウザに直接接続しました。 – munirah

+0

私はあなたのコードにExpectedConditionsメソッドをどこに置くべきかを具体的に決定できますか?私は分度器で新しいです – munirah

+0

私はあなたが示唆したことをしましたが、それは私にこのメッセージを表示します:失敗:不可視 待ち時間10009ms後に – munirah

関連する問題