Question
TSPI
US
Last activity: 6 Aug 2024 10:34 EDT
Regarding Adding the xpath for the custom step of scenario testing
Hi Team ,
I am trying to validate the values of dropdown control (count of values in dropdown) in Pega scenario testing by using the custom step .
In custom step its asking for xPath , i tried the below logic but its throwing error as element not found. could someone help me on rectifying it .
var xpath = "//select[@data-test-id='202308040914140115669']/option";
function countDropdownOptions(xpathExpression) {
var result = document.evaluate(xpathExpression, document, null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
return result.snapshotLength;
}
var optionCount = countDropdownOptions(xpath);
console.log('Number of values in the dropdown:',optionCount);
var expectedCount = 3;
if(optionCount === expectedCount) {
console.log('Dropdown Validation passed.');
}
else {
Hi Team ,
I am trying to validate the values of dropdown control (count of values in dropdown) in Pega scenario testing by using the custom step .
In custom step its asking for xPath , i tried the below logic but its throwing error as element not found. could someone help me on rectifying it .
var xpath = "//select[@data-test-id='202308040914140115669']/option";
function countDropdownOptions(xpathExpression) {
var result = document.evaluate(xpathExpression, document, null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
return result.snapshotLength;
}
var optionCount = countDropdownOptions(xpath);
console.log('Number of values in the dropdown:',optionCount);
var expectedCount = 3;
if(optionCount === expectedCount) {
console.log('Dropdown Validation passed.');
}
else {
console.error('dropdown validation failied.Expected ' + expectedCount + 'but found ' + optionCount);
}
Error :
Element not found with specified xPath
Note :
If i execute same with console it should return 3 but its returing 0