2017-11-16 4 views
0

テストケース:名前フィールドに「英数字」データを1つずつ送信し、「無効なデータ"検証メッセージが表示されているかどうか検証メッセージが表示されているかどうかを確認する方法

My Spec file code is below。

//Testcase 3 : To verify whether "Name" field validation message is displaying or not 
// "name field is a required" field 
using(CertificationTestData.testData, function(testdata){ 

    it('validation of Certificate Name field content',()=>{ 

     //To clear the "Ceritication Name" field data 
     page.getCertificationNameField().clear(); 

     //enter each type of test data one at a time 
     page.getCertificationNameField().sendKeys(testdata.data); 

     browser.driver.sleep(5000); 

     page.getAnyWhereCertificationPage().click();   

     //To check whether any validation message is displaying for "Name" field 
     expect(page.getValidationMessage().isDisplayed()).toBeFalsy(); 
    }); 
}); 

私の外部テスト・データ・ファイルには、私のPOファイルのコードは以下の通りです

testData :[ 
    {data:"abcd"}, 
    {data: "1234"}, 
    {data:"[email protected]#$%#"}, 
    {data:"[email protected]##$"} 
], 

を下回っています。

//To return "Certification Name" field 
getCertificationNameField(){ 
    return element(by.css('input[formcontrolname="CertificationsName"]')); 
} 


//To return validation message 
getValidationMessage(){ 
    return element(by.className('ui-message ui-messages-error ui-corner-all')); 
} 

私がテストスクリプトを実行すると、以下のエラーメッセージが表示されます。

should test certificate tab validation of Certificate Name field content 

は - 失敗しました:ロケータを使用して見つかりませ要素:(CSSセレクタ、.ui-message.ui - メッセージ - error.uiコーナー-すべて)

によっては、かどうかを確認する方法はありません検証メッセージが表示されているかどうか?

答えて

0

isDisplayed()は、ElementFinderを実行するときに必ず要素の存在を要求し、そのエラーを返します。

要素が表示されている場合は、isDisplayed()isPresent()に置き換えてください。

その他のチェックif(element.isPresent()){expect(element.isDisplayed()).toBeFalsy()} else {expect(element.isPresent()).toBeFalsy()} ...少し奇妙で冗長ですが...。

関連する問題