Added split row validation fix

This commit is contained in:
2025-05-14 11:43:12 -07:00
parent 51314bc4a3
commit 77a3b83ca7
2 changed files with 457 additions and 96 deletions

Binary file not shown.

View File

@@ -416,11 +416,34 @@ const steps = [
{ {
description: 'Validate Language Arts concepts label', description: 'Validate Language Arts concepts label',
action: async () => { action: async () => {
const elementText = await driver.findElement(By.css('.concept-item:nth-child(1) > a')).getText(); try {
if (elementText !== 'Language Arts') { const element = await driver.findElement(By.css('.concept-item:nth-child(1) > a'));
throw new Error(`Expected: "Language Arts"; Actual: "${elementText}"`);
//Get different versions of the text for debugging
const fullText = await element.getText();
//Check for the expected text in different ways
const expectedText = 'Language Arts';
const trimmedFullText = fullText.trim();
const firstLine = trimmedFullText.split('\n')[0].trim();
//Try multiple matching strategies
if (firstLine.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text found in first line`);
} else if (trimmedFullText.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text found within full text`);
} else {
throw new Error(
`Text validation failed.\nExpected: "${expectedText}"\n` +
`Full text: "${fullText}"\n` +
`First line: "${firstLine}"\n`
);
}
} catch (error) {
console.error('Detailed error during validation:', error);
throw error; //Re-throw after logging
} }
console.log('Passed: Language Arts concepts label matched as expected');
} }
}, },
@@ -464,11 +487,34 @@ const steps = [
{ {
description: 'Validate Mathematics concepts label', description: 'Validate Mathematics concepts label',
action: async () => { action: async () => {
const elementText = await driver.findElement(By.css('.concept-item:nth-child(2) > a')).getText(); try {
if (elementText !== 'Mathematics') { const element = await driver.findElement(By.css('.concept-item:nth-child(2) > a'));
throw new Error(`Expected: "Mathematics"; Actual: "${elementText}"`);
//Get different versions of the text for debugging
const fullText = await element.getText();
//Check for the expected text in different ways
const expectedText = 'Mathematics';
const trimmedFullText = fullText.trim();
const firstLine = trimmedFullText.split('\n')[0].trim();
//Try multiple matching strategies
if (firstLine.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text found in first line`);
} else if (trimmedFullText.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text found within full text`);
} else {
throw new Error(
`Text validation failed.\nExpected: "${expectedText}"\n` +
`Full text: "${fullText}"\n` +
`First line: "${firstLine}"\n`
);
}
} catch (error) {
console.error('Detailed error during validation:', error);
throw error; //Re-throw after logging
} }
console.log('Passed: Mathematics concepts label matched as expected');
} }
}, },
@@ -512,11 +558,34 @@ const steps = [
{ {
description: 'Validate Science concepts label', description: 'Validate Science concepts label',
action: async () => { action: async () => {
const elementText = await driver.findElement(By.css('.concept-item:nth-child(3) > a')).getText(); try {
if (elementText !== 'Science') { const element = await driver.findElement(By.css('.concept-item:nth-child(3) > a'));
throw new Error(`Expected: "Science"; Actual: "${elementText}"`);
//Get different versions of the text for debugging
const fullText = await element.getText();
//Check for the expected text in different ways
const expectedText = 'Science';
const trimmedFullText = fullText.trim();
const firstLine = trimmedFullText.split('\n')[0].trim();
//Try multiple matching strategies
if (firstLine.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text found in first line`);
} else if (trimmedFullText.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text found within full text`);
} else {
throw new Error(
`Text validation failed.\nExpected: "${expectedText}"\n` +
`Full text: "${fullText}"\n` +
`First line: "${firstLine}"\n`
);
}
} catch (error) {
console.error('Detailed error during validation:', error);
throw error; //Re-throw after logging
} }
console.log('Passed: Science concepts label matched as expected');
} }
}, },
@@ -560,11 +629,34 @@ const steps = [
{ {
description: 'Validate Social Studies concepts label', description: 'Validate Social Studies concepts label',
action: async () => { action: async () => {
const elementText = await driver.findElement(By.css('.concept-item:nth-child(4) > a')).getText(); try {
if (elementText !== 'Social Studies') { const element = await driver.findElement(By.css('.concept-item:nth-child(4) > a'));
throw new Error(`Expected: "Social Studies"; Actual: "${elementText}"`);
//Get different versions of the text for debugging
const fullText = await element.getText();
//Check for the expected text in different ways
const expectedText = 'Social Studies';
const trimmedFullText = fullText.trim();
const firstLine = trimmedFullText.split('\n')[0].trim();
//Try multiple matching strategies
if (firstLine.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text found in first line`);
} else if (trimmedFullText.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text found within full text`);
} else {
throw new Error(
`Text validation failed.\nExpected: "${expectedText}"\n` +
`Full text: "${fullText}"\n` +
`First line: "${firstLine}"\n`
);
}
} catch (error) {
console.error('Detailed error during validation:', error);
throw error; //Re-throw after logging
} }
console.log('Passed: Social Studies concepts label matched as expected');
} }
}, },
@@ -608,11 +700,34 @@ const steps = [
{ {
description: 'Validate World Languages concepts label', description: 'Validate World Languages concepts label',
action: async () => { action: async () => {
const elementText = await driver.findElement(By.css('.concept-item:nth-child(5) > a')).getText(); try {
if (elementText !== 'World Languages') { const element = await driver.findElement(By.css('.concept-item:nth-child(5) > a'));
throw new Error(`Expected: "World Languages"; Actual: "${elementText}"`);
//Get different versions of the text for debugging
const fullText = await element.getText();
//Check for the expected text in different ways
const expectedText = 'World Languages';
const trimmedFullText = fullText.trim();
const firstLine = trimmedFullText.split('\n')[0].trim();
//Try multiple matching strategies
if (firstLine.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text found in first line`);
} else if (trimmedFullText.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text found within full text`);
} else {
throw new Error(
`Text validation failed.\nExpected: "${expectedText}"\n` +
`Full text: "${fullText}"\n` +
`First line: "${firstLine}"\n`
);
}
} catch (error) {
console.error('Detailed error during validation:', error);
throw error; //Re-throw after logging
} }
console.log('Passed: World Languages concepts label matched as expected');
} }
}, },
@@ -852,11 +967,34 @@ const steps = [
{ {
description: 'Validate Algebra label', description: 'Validate Algebra label',
action: async () => { action: async () => {
const elementText = await driver.findElement(By.css('.list-group-item:nth-child(1) > .clickable')).getText(); try {
if (elementText !== 'Algebra') { const element = await driver.findElement(By.css('.list-group-item:nth-child(1) > .clickable'));
throw new Error(`Expected: "Algebra"; Actual: "${elementText}"`);
//Get different versions of the text for debugging
const fullText = await element.getText();
//Check for the expected text in different ways
const expectedText = 'Algebra';
const trimmedFullText = fullText.trim();
const firstLine = trimmedFullText.split('\n')[0].trim();
//Try multiple matching strategies
if (firstLine.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text found in first line`);
} else if (trimmedFullText.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text found within full text`);
} else {
throw new Error(
`Text validation failed.\nExpected: "${expectedText}"\n` +
`Full text: "${fullText}"\n` +
`First line: "${firstLine}"\n`
);
}
} catch (error) {
console.error('Detailed error during validation:', error);
throw error; //Re-throw after logging
} }
console.log('Passed: Algebra label matched as expected');
} }
}, },
@@ -1020,11 +1158,34 @@ const steps = [
{ {
description: 'Validate General Mathematics label', description: 'Validate General Mathematics label',
action: async () => { action: async () => {
const elementText = await driver.findElement(By.css('.list-group-item:nth-child(4) > .clickable')).getText(); try {
if (elementText !== 'General Mathematics') { const element = await driver.findElement(By.css('.list-group-item:nth-child(4) > .clickable'));
throw new Error(`Expected: "General Mathematics"; Actual: "${elementText}"`);
//Get different versions of the text for debugging
const fullText = await element.getText();
//Check for the expected text in different ways
const expectedText = 'General Mathematics';
const trimmedFullText = fullText.trim();
const firstLine = trimmedFullText.split('\n')[0].trim();
//Try multiple matching strategies
if (firstLine.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text found in first line`);
} else if (trimmedFullText.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text found within full text`);
} else {
throw new Error(
`Text validation failed.\nExpected: "${expectedText}"\n` +
`Full text: "${fullText}"\n` +
`First line: "${firstLine}"\n`
);
}
} catch (error) {
console.error('Detailed error during validation:', error);
throw error; //Re-throw after logging
} }
console.log('Passed: General Mathematics label matched as expected');
} }
}, },
@@ -1128,11 +1289,34 @@ const steps = [
{ {
description: 'Validate Math Process Standards label', description: 'Validate Math Process Standards label',
action: async () => { action: async () => {
const elementText = await driver.findElement(By.css('.list-group-item:nth-child(6) > .clickable')).getText(); try {
if (elementText !== 'Math Process Standards') { const element = await driver.findElement(By.css('.list-group-item:nth-child(6) > .clickable'));
throw new Error(`Expected: "Math Process Standards"; Actual: "${elementText}"`);
//Get different versions of the text for debugging
const fullText = await element.getText();
//Check for the expected text in different ways
const expectedText = 'Math Process Standards';
const trimmedFullText = fullText.trim();
const firstLine = trimmedFullText.split('\n')[0].trim();
//Try multiple matching strategies
if (firstLine.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text found in first line`);
} else if (trimmedFullText.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text found within full text`);
} else {
throw new Error(
`Text validation failed.\nExpected: "${expectedText}"\n` +
`Full text: "${fullText}"\n` +
`First line: "${firstLine}"\n`
);
}
} catch (error) {
console.error('Detailed error during validation:', error);
throw error; //Re-throw after logging
} }
console.log('Passed: Math Process Standards label matched as expected');
} }
}, },
@@ -1296,11 +1480,34 @@ const steps = [
{ {
description: 'Validate Process Standards label', description: 'Validate Process Standards label',
action: async () => { action: async () => {
const elementText = await driver.findElement(By.css('.list-group-item:nth-child(9) > .clickable')).getText(); try {
if (elementText !== 'Process Standards') { const element = await driver.findElement(By.css('.list-group-item:nth-child(9) > .clickable'));
throw new Error(`Expected: "Process Standards"; Actual: "${elementText}"`);
//Get different versions of the text for debugging
const fullText = await element.getText();
//Check for the expected text in different ways
const expectedText = 'Process Standards';
const trimmedFullText = fullText.trim();
const firstLine = trimmedFullText.split('\n')[0].trim();
//Try multiple matching strategies
if (firstLine.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text found in first line`);
} else if (trimmedFullText.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text found within full text`);
} else {
throw new Error(
`Text validation failed.\nExpected: "${expectedText}"\n` +
`Full text: "${fullText}"\n` +
`First line: "${firstLine}"\n`
);
}
} catch (error) {
console.error('Detailed error during validation:', error);
throw error; //Re-throw after logging
} }
console.log('Passed: Process Standards label matched as expected');
} }
}, },
@@ -1672,11 +1879,34 @@ const steps = [
{ {
description: 'Validate Concept - Change of Parameter-Constant-Coefficient label', description: 'Validate Concept - Change of Parameter-Constant-Coefficient label',
action: async () => { action: async () => {
const elementText = await driver.findElement(By.css('.list-group-item:nth-child(1) > .clickable')).getText(); try {
if (elementText !== 'Change of Parameter/Constant/Coefficient') { const element = await driver.findElement(By.css('.list-group-item:nth-child(1) > .clickable'));
throw new Error(`Expected: Concept - "Change of Parameter/Constant/Coefficient"; Actual: "${elementText}"`);
//Get different versions of the text for debugging
const fullText = await element.getText();
//Check for the expected text in different ways
const expectedText = 'Change of Parameter/Constant/Coefficient';
const trimmedFullText = fullText.trim();
const firstLine = trimmedFullText.split('\n')[0].trim();
//Try multiple matching strategies
if (firstLine.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text found in first line`);
} else if (trimmedFullText.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text found within full text`);
} else {
throw new Error(
`Text validation failed.\nExpected: "${expectedText}"\n` +
`Full text: "${fullText}"\n` +
`First line: "${firstLine}"\n`
);
}
} catch (error) {
console.error('Detailed error during validation:', error);
throw error; //Re-throw after logging
} }
console.log('Passed: Concept - Change of Parameter/Constant/Coefficient label matched as expected');
} }
}, },
@@ -1720,11 +1950,34 @@ const steps = [
{ {
description: 'Validate Concept - Equations 1 label', description: 'Validate Concept - Equations 1 label',
action: async () => { action: async () => {
const elementText = await driver.findElement(By.css('.list-group-item:nth-child(2) > .clickable')).getText(); try {
if (elementText !== 'Equations/Inequalities & Functions') { const element = await driver.findElement(By.css('.list-group-item:nth-child(2) > .clickable'));
throw new Error(`Expected: Concept - "Equations/Inequalities & Functions"; Actual: "${elementText}"`);
//Get different versions of the text for debugging
const fullText = await element.getText();
//Check for the expected text in different ways
const expectedText = 'Equations/Inequalities & Functions';
const trimmedFullText = fullText.trim();
const firstLine = trimmedFullText.split('\n')[0].trim();
//Try multiple matching strategies
if (firstLine.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text found in first line`);
} else if (trimmedFullText.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text found within full text`);
} else {
throw new Error(
`Text validation failed.\nExpected: "${expectedText}"\n` +
`Full text: "${fullText}"\n` +
`First line: "${firstLine}"\n`
);
}
} catch (error) {
console.error('Detailed error during validation:', error);
throw error; //Re-throw after logging
} }
console.log('Passed: Concept - Equations/Inequalities & Functions label matched as expected');
} }
}, },
@@ -1768,11 +2021,34 @@ const steps = [
{ {
description: 'Validate Concept - Equations-Inequalities & Functions-Solving label', description: 'Validate Concept - Equations-Inequalities & Functions-Solving label',
action: async () => { action: async () => {
const elementText = await driver.findElement(By.css('.list-group-item:nth-child(3) > .clickable')).getText(); try {
if (elementText !== 'Equations/Inequalities & Functions/Solving') { const element = await driver.findElement(By.css('.list-group-item:nth-child(3) > .clickable'));
throw new Error(`Expected: Concept - "Equations/Inequalities & Functions/Solving"; Actual: "${elementText}"`);
//Get different versions of the text for debugging
const fullText = await element.getText();
//Check for the expected text in different ways
const expectedText = 'Equations/Inequalities & Functions/Solving';
const trimmedFullText = fullText.trim();
const firstLine = trimmedFullText.split('\n')[0].trim();
//Try multiple matching strategies
if (firstLine.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text found in first line`);
} else if (trimmedFullText.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text found within full text`);
} else {
throw new Error(
`Text validation failed.\nExpected: "${expectedText}"\n` +
`Full text: "${fullText}"\n` +
`First line: "${firstLine}"\n`
);
}
} catch (error) {
console.error('Detailed error during validation:', error);
throw error; //Re-throw after logging
} }
console.log('Passed: Concept - Equations/Inequalities & Functions/Solving label matched as expected');
} }
}, },
@@ -1816,11 +2092,34 @@ const steps = [
{ {
description: 'Validate Concept - Inequalities label', description: 'Validate Concept - Inequalities label',
action: async () => { action: async () => {
const elementText = await driver.findElement(By.css('.list-group-item:nth-child(4) > .clickable')).getText(); try {
if (elementText !== 'Inequalities') { const element = await driver.findElement(By.css('.list-group-item:nth-child(4) > .clickable'));
throw new Error(`Expected: Concept - "Inequalities"; Actual: "${elementText}"`);
//Get different versions of the text for debugging
const fullText = await element.getText();
//Check for the expected text in different ways
const expectedText = 'Inequalities';
const trimmedFullText = fullText.trim();
const firstLine = trimmedFullText.split('\n')[0].trim();
//Try multiple matching strategies
if (firstLine.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text found in first line`);
} else if (trimmedFullText.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text found within full text`);
} else {
throw new Error(
`Text validation failed.\nExpected: "${expectedText}"\n` +
`Full text: "${fullText}"\n` +
`First line: "${firstLine}"\n`
);
}
} catch (error) {
console.error('Detailed error during validation:', error);
throw error; //Re-throw after logging
} }
console.log('Passed: Concept - Inequalities label matched as expected');
} }
}, },
@@ -2106,13 +2405,36 @@ const steps = [
//Writing label //Writing label
{ {
description: 'Validate Inequalities label', description: 'Validate Writing label',
action: async () => { action: async () => {
const elementText = await driver.findElement(By.css('.clickable')).getText(); try {
if (elementText !== 'Writing') { const element = await driver.findElement(By.css('.clickable'));
throw new Error(`Expected: "Writing" label; Actual: "${elementText}"`);
//Get different versions of the text for debugging
const fullText = await element.getText();
//Check for the expected text in different ways
const expectedText = 'Writing';
const trimmedFullText = fullText.trim();
const firstLine = trimmedFullText.split('\n')[0].trim();
//Try multiple matching strategies
if (firstLine.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text found in first line`);
} else if (trimmedFullText.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text found within full text`);
} else {
throw new Error(
`Text validation failed.\nExpected: "${expectedText}"\n` +
`Full text: "${fullText}"\n` +
`First line: "${firstLine}"\n`
);
}
} catch (error) {
console.error('Detailed error during validation:', error);
throw error; //Re-throw after logging
} }
console.log('Passed: Writing label matched as expected');
} }
}, },
@@ -2680,29 +3002,47 @@ const steps = [
{ {
description: 'Validate Applications of Linear Systems description text', description: 'Validate Applications of Linear Systems description text',
action: async () => { action: async () => {
const elementText = await driver.findElement(By.css('.card:nth-child(6) .lo-descr')).getText(); try {
if (elementText !== 'Unit: Systems of Equations and Inequalities') { const element = await driver.findElement(By.css('.card:nth-child(6) .lo-descr'));
throw new Error(`Expected: "Unit: Systems of Equations and Inequalities" text; Actual: "${elementText}"`);
//Get different versions of the text for debugging
const fullText = await element.getText();
//Try XPath approach
let xpathText;
try {
xpathText = await driver.findElement(
By.xpath('//*[contains(@class, "card")][6]//*[contains(@class, "lo-descr")]/text()[normalize-space()]')
).getText();
} catch (e) {
xpathText = "XPath method failed: " + e.message;
} }
console.log('Passed: Unit: Systems of Equations and Inequalities text matched as expected');
}
},
//Check for the expected text in different ways
{
description: 'Validate Applications of Linear Systems description text',
action: async () => {
const elementText = await driver.findElement(By.css('.card:nth-child(6) .lo-descr')).getText();
const expectedText = 'Unit: Systems of Equations and Inequalities'; const expectedText = 'Unit: Systems of Equations and Inequalities';
const trimmedFullText = fullText.trim();
const firstLine = trimmedFullText.split('\n')[0].trim();
// Trim the element text to avoid mismatch due to extra spaces or appended text //Try multiple matching strategies
if (elementText.trim() !== expectedText) { if (firstLine.includes(expectedText)) {
throw new Error(`Expected: "${expectedText}" text; Actual: "${elementText}"`); console.log(`Passed: "${expectedText}" text found in first line`);
} else if (trimmedFullText.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text found within full text`);
} else if (xpathText.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text found via XPath method`);
} else {
throw new Error(
`Text validation failed.\nExpected: "${expectedText}"\n` +
`Full text: "${fullText}"\n` +
`First line: "${firstLine}"\n` +
`XPath result: "${xpathText}"`
);
} }
console.log('Passed: Unit: Systems of Equations and Inequalities text matched as expected'); } catch (error) {
console.error('Detailed error during validation:', error);
throw error; //Re-throw after logging
}
} }
}, },
@@ -2718,8 +3058,7 @@ const steps = [
} }
}, },
//Content Set label
{ {
description: 'Validate Applications of Linear Systems content set label', description: 'Validate Applications of Linear Systems content set label',
action: async () => { action: async () => {
@@ -2735,7 +3074,6 @@ const steps = [
} }
}, },
//Applications of Linear Systems alignment icon //Applications of Linear Systems alignment icon
{ {
description: 'Verify Applications of Linear Systems alignment icon is present', description: 'Verify Applications of Linear Systems alignment icon is present',
@@ -2884,11 +3222,34 @@ const steps = [
{ {
description: 'Validate Direct Variation description text', description: 'Validate Direct Variation description text',
action: async () => { action: async () => {
const elementText = await driver.findElement(By.css('.card:nth-child(7) .lo-descr')).getText(); try {
if (elementText !== 'Unit: Linear Functions') { const element = await driver.findElement(By.css('.card:nth-child(7) .lo-descr'));
throw new Error(`Expected: "Unit: Linear Functions" text; Actual: "${elementText}"`);
//Get different versions of the text for debugging
const fullText = await element.getText();
//Check for the expected text in different ways
const expectedText = 'Unit: Linear Functions';
const trimmedFullText = fullText.trim();
const firstLine = trimmedFullText.split('\n')[0].trim();
//Try multiple matching strategies
if (firstLine.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text found in first line`);
} else if (trimmedFullText.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text found within full text`);
} else {
throw new Error(
`Text validation failed.\nExpected: "${expectedText}"\n` +
`Full text: "${fullText}"\n` +
`First line: "${firstLine}"\n`
);
}
} catch (error) {
console.error('Detailed error during validation:', error);
throw error; //Re-throw after logging
} }
console.log('Passed: Unit: Linear Functions text matched as expected');
} }
}, },