2017-11-16 15 views
0

테스트 사례 : 이름 필드에 한 번에 하나씩 "영문자"데이터를 보내고 "유효하지 않은 데이터 "유효성 확인 메시지가 표시되는지 여부각도기를 사용하여 유효성 검사 메시지가 표시되는지 여부를 확인하는 방법

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(); 
    }); 
}); 

내 외부 테스트 데이터 파일 내 포 파일의 코드는 다음과 같습니다

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()} ... 조금 이상하고 장황하다.