구성요소 테스트 작업 재정의
에 특정한 HTML 속성을 사용하여 특정 페이지 구성요소의 테스트 속성을 변경합니다 Automated Test Framework.
시작하기 전에
이 태스크 정보
구성요소를 검색할 때 Automated Test Framework 설정 가능한 구성요소인지 또는 클릭 가능한 구성요소인지 여부와 같이 지원하는 상호 작용을 결정합니다. 구성요소를 설정할 수 있는 Automated Test Framework 경우 설정할 수 있는 필드 유형을 결정합니다. 사용자 지정 구성요소의 작업 또는 필드 유형을 잘못 결정하거나 구성요소에 하나의 엔터티로 처리해야 하는 여러 DOM 요소가 포함된 경우 Automated Test Framework 와 관련된 Automated Test FrameworkHTML 속성을 사용하여 명시적으로 설정합니다.
sn-atf-clickable 및 sn-atf-settable 속성 사용
sn-atf-clickable 및 sn-atf-settable 속성을 사용하여 요소와 해당 하위 요소를 사용자 지정 클릭 가능 또는 사용자 지정 설정 가능 구성요소로 처리하도록 지정합니다.
시작하기 전에
프로시저
예
//A custom clickable component
<div sn-atf-clickable="true" sn-atf-disabled id="customClickable">
<button id="customButton">Click me</button>
</div>
<script>
var customClickableDiv = document.getElementById("customClickable");
customClickableDiv.addEventListener('sn-atf-click', function() {
document.getElementById('customButton').click();
});
</script>
//A custom settable component
<div sn-atf-settable="true" id="customSettable" sn-atf-component-value="A default value">
<input id="customInput" value="A default value"></input>
</div>
<script>
var customSettableDiv = document.getElementById("customSettable");
customSettableDiv.addEventListener('sn-atf-setvalue', function(event) {
var newValue = event.detail.newValue;
document.getElementById("customInput").value = newValue;
});
</script>
sn-atf-class 속성 사용
sn-atf-class 속성을 사용하여 클릭 가능하거나 설정 가능한 사용자 지정 구성요소를 테스트할 때 사용할 JavaScript 객체를 지정합니다. 사용자 지정 JavaScript 객체를 작성하여 사용자 지정 구성요소에 사용할 수 있는 테스트 작업을 지정합니다.
시작하기 전에
이 태스크 정보
sn-atf-class 속성을 할당하여 사용자 지정 구성요소에 사용할 수 있는 테스트 작업을 수동으로 지정할 수 있습니다. 속성 값을 구성요소 테스트 작업을 포함하는 JavaScript 객체의 이름으로 설정합니다. 테스트 가능한 사용자 지정 구성요소는 클릭 가능하거나 설정 가능해야 하며 이 분류는 JavaScript 객체에 필요한 기능과 속성을 결정합니다. 테스트 가능한 페이지 구성요소 요구 사항은 문서를 참조하십시오 사용자 지정 UI 테스트 단계 .프로시저
예
//A custom clickable component
<form>
<div sn-atf-class="MyClickableComponent">
<label for="a_clickable_checkbox">MyClickableComponent</label>
<input type="checkbox" id="a_clickable_checkbox" checked="true"/>
</div>
</form>
<script>
var MyClickableComponent = {
// The constructor must have this signature, but you can perform additional setup after the $super(element, area) call
initialize: function($super, element, area) {
$super(element, area);
},
click: function() {
document.getElementById('a_clickable_checkbox').click();
return {success: true};
},
// The function returns an object with a result attribute of type String
getValue: function() {
var isChecked = document.getElementById('a_clickable_checkbox').checked ? "true" : "false";
return {success: true, result: isChecked};
},
// The function returns an object with a result attribute of type Boolean
isDisabled: function() {
if (document.getElementById('a_clickable_checkbox').disabled)
return {success: true, result: true};
return {success: true, result: false};
},
};
</script>
//A custom settable component
<form>
<div sn-atf-class="MySettableComponent">
<label for="a_settable_checkbox">MySettableComponent</label>
<input type="checkbox" id="a_settable_checkbox" checked="true"/>
</div>
</form>
<script>
var MySettableComponent = {
// This attribute is required for settable components
isSettable: true,
// The constructor must have this signature, but you can perform additional setup after the $super(element, area) call
initialize: function($super, element, area) {
$super(element, area);
},
// The value parameter is a string
setValue: function(value) {
document.getElementById('a_settable_checkbox').checked = (value == "true");
return {success: true};
},
// The function returns an object with a result attribute of type String
getValue: function() {
var isChecked = document.getElementById('a_settable_checkbox').checked ? "true" : "false";
return {success: true, result: isChecked};
},
// The function returns an object with a result attribute of type Boolean
isDisabled: function() {
if (document.getElementById('a_settable_checkbox').disabled)
return {success: true, result: true};
return {success: true, result: false};
},
};
</script>
참조 및 기록 선택기
사용자 지정 UI 단계를 사용하여 sn-reference-picker 및 sn-record-picker 각도 지시문의 값을 조작합니다. 참조 선택기의 값은 선택한 기록의 sys_id 반환합니다. 기록 선택기의 값은 해당 기록 선택기에 대해 선택된 값 필드를 반환합니다. 두 요소 모두 해당 값으로 설정할 기록을 선택하여 설정할 수 있습니다.