2017-06-27 3 views
0

次のメソッドは、データテーブルを通過させ、アサーションを実行しないで、自動的にキュウリステップを通過するものをアサートしないためです。分度器:getText()が実行されていないときの.then

Then(/^the following <fields> are displayed in the Method Information panel$/, (table) => { 
    var hashes = table.hashes(); 
    var expectedValues: string[] = new Array(); 

    return hashes.forEach(function (hash) { 
     console.log("In For Each"); 
     expectedValues.push(hash.fields); 
     var index = expectedValues.length - 1; 
     console.log(expectedValues[index]) 
     expectedValues[index] = expectedValues[index].replace(' ', ''); 

     return element(by.id("label" + expectedValues[index])).getText() 
      .then(function (actualValues) { 
       console.log("In Then:" + actualValues); 
       report.takeScreenshot(); 
       return expecting(actualValues).to.deeply.equal(expectedValues[index]); 
      }, function (err) { 
       report.logError("An error occurred while comparing values." + err); 
      }); 
    }, function (err) { 
     report.logError("An error occurred while comparing values." + err); 
    }); 
}); 

コンソールログには、次のようになります。あなたがライン上でリターンを削除した場合

In For Each 
Name 
In For Each 
Description 
In For Each 
Type 
In For Each 
Instrument System 
    √ Then the following <fields> are displayed in the Method Information panel 
    | fields   | 
    | Name    | 
    | Description  | 
    | Type    | 
    | Instrument System | 

答えて

0

return element(by.id("label" + expectedValues[index])).getText() 

それは、その後に続けていますか?

私はTypeScriptに慣れていませんが、ハッシュでリターンを使用する必要がありますか?

return hashes.forEach(function (hash) { 

の代わりにgetTextに、あなたは

getAttribute('textContent')

または

getAttribute('value')

+0

で何かを得る両方のリターンを取り除かないと、それはまだ、その後にはなりません。私は個々のリターンを個別に取り除きましたが、それでもそれには入りません。 – cpegs

+0

getText()を切り替えても助けにならなかった – cpegs

+0

あなたは本当ですか**要素(by.id( "label" + expectedValues [index]))**何かを探しますか? ところで、私は見たことがありません**予想**の代わりに**期待して**。キュウリなの?また、私は期待に戻りません。それは必要ですか ? – bwarff

関連する問題