Open
Conversation
DerekCacciotti
requested changes
Dec 8, 2025
Comment on lines
+441
to
+446
| var livingArrangementSelect = new SelectElement(livingArrangementDropdown); | ||
| livingArrangementSelect.SelectByValue("05"); // Select "Other" | ||
| driver.WaitForUpdatePanel(3); | ||
| driver.WaitForReady(3); | ||
| Thread.Sleep(500); | ||
| _output.WriteLine($"[INFO] Selected 'Other' in Living Arrangement for Child {childNumber}"); |
Owner
There was a problem hiding this comment.
Make sure you test for a textbox for when other is selected.
Contributor
Author
There was a problem hiding this comment.
Yup here it is
protected void TestRelationshipOtherSpecify(IPookieWebDriver driver, int childNumber)
{
_output.WriteLine($"\n[INFO] Testing Relationship to PC1 'Other' validation for Child {childNumber}");
// Select "Other" (09) in Relationship to PC1
var relationshipDropdown = driver.FindElements(By.CssSelector($"select.form-control[id*='Child{childNumber}_ddlRelation2PC1']"))
.FirstOrDefault(el => el.Displayed)
?? throw new InvalidOperationException($"Child {childNumber} Relationship dropdown was not found.");
var relationshipSelect = new SelectElement(relationshipDropdown);
relationshipSelect.SelectByValue("09"); // Select "Other"
driver.WaitForUpdatePanel(3);
driver.WaitForReady(3);
Thread.Sleep(500);
_output.WriteLine($"[INFO] Selected 'Other' in Relationship to PC1 for Child {childNumber}");
// Verify specify field appears
var specifyDiv = driver.FindElements(By.CssSelector($"div[id*='Child{childNumber}_divRelation2PC1Specify']"))
.FirstOrDefault();
Assert.NotNull(specifyDiv);
Assert.True(specifyDiv.Displayed, $"Relationship specify field should be visible for Child {childNumber}");
_output.WriteLine($"[PASS] Relationship specify field appeared for Child {childNumber}");
// Clear the specify field if it has any value
var specifyInput = specifyDiv.FindElements(By.CssSelector($"input[id*='Child{childNumber}_txtRelation2PC1Specify']"))
.FirstOrDefault();
if (specifyInput != null && specifyInput.Displayed)
{
specifyInput.Clear();
_output.WriteLine($"[INFO] Cleared Relationship specify field for Child {childNumber}");
}
// Submit without filling specify field
var submitButton = FindSubmitButton(driver);
CommonTestHelper.ClickElement(driver, submitButton);
driver.WaitForUpdatePanel(30);
driver.WaitForReady(30);
Thread.Sleep(1000);
_output.WriteLine($"[INFO] Clicked Submit with empty Relationship specify for Child {childNumber}");
// Switch back to Family/Children tab (may reset to PC1)
ActivateTab(driver, "#tab_CHILDREN a[href='#CHILDREN']", "Family/Other Children");
Thread.Sleep(500);
// Verify validation message
var validationMessage = FindValidationMessage(driver, $"Child{childNumber} Relationship specify validation",
$"Please specify Child{childNumber} relationship to PC 1");
Assert.NotNull(validationMessage);
_output.WriteLine($"[PASS] Validation displayed for Child {childNumber}: {validationMessage!.Text.Trim()}");
// Change to a non-Other option
relationshipDropdown = driver.FindElements(By.CssSelector($"select.form-control[id*='Child{childNumber}_ddlRelation2PC1']"))
.FirstOrDefault(el => el.Displayed)
?? throw new InvalidOperationException($"Child {childNumber} Relationship dropdown was not found after validation.");
relationshipSelect = new SelectElement(relationshipDropdown);
var nonOtherOption = relationshipSelect.Options.FirstOrDefault(opt => !string.IsNullOrWhiteSpace(opt.GetAttribute("value")) && opt.GetAttribute("value") != "09");
if (nonOtherOption != null)
{
relationshipSelect.SelectByValue(nonOtherOption.GetAttribute("value"));
driver.WaitForUpdatePanel(3);
driver.WaitForReady(3);
Thread.Sleep(500);
_output.WriteLine($"[INFO] Changed Relationship to non-Other option for Child {childNumber}: {nonOtherOption.Text.Trim()}");
}
// Verify specify field hides
Thread.Sleep(500);
specifyDiv = driver.FindElements(By.CssSelector($"div[id*='Child{childNumber}_divRelation2PC1Specify']"))
.FirstOrDefault();
var isHidden = specifyDiv == null || !specifyDiv.Displayed || specifyDiv.GetAttribute("style").Contains("display: none");
Assert.True(isHidden, $"Relationship specify field should be hidden for Child {childNumber}");
_output.WriteLine($"[PASS] Relationship specify field hidden after selecting non-Other option for Child {childNumber}");
}
protected void TestFirstNameBlankValidation(IPookieWebDriver driver, int childNumber)
{
_output.WriteLine($"\n[INFO] Testing First Name blank validation for Child {childNumber}");
// Get the current first name to restore later
var firstNameInput = driver.FindElements(By.CssSelector($"input.form-control[id*='Child{childNumber}_txtChildFName']"))
.FirstOrDefault(el => el.Displayed)
?? throw new InvalidOperationException($"Child {childNumber} First Name input was not found.");
var originalFirstName = firstNameInput.GetAttribute("value");
// Clear the first name field
firstNameInput.Clear();
WebElementHelper.SetInputValue(driver, firstNameInput, "", $"Child {childNumber} First Name (clear)", triggerBlur: true);
_output.WriteLine($"[INFO] Cleared First Name for Child {childNumber}");
// Submit without first name
var submitButton = FindSubmitButton(driver);
CommonTestHelper.ClickElement(driver, submitButton);
driver.WaitForUpdatePanel(30);
driver.WaitForReady(30);
Thread.Sleep(1000);
_output.WriteLine($"[INFO] Clicked Submit with blank First Name for Child {childNumber}");
// Switch back to Family/Children tab (may reset to PC1)
ActivateTab(driver, "#tab_CHILDREN a[href='#CHILDREN']", "Family/Other Children");
Thread.Sleep(500);
// Verify validation message
var validationMessage = FindValidationMessage(driver, $"Child{childNumber} First Name blank validation",
$"Other child {childNumber}: First Name cannot be blank");
Assert.NotNull(validationMessage);
_output.WriteLine($"[PASS] Validation displayed for Child {childNumber}: {validationMessage!.Text.Trim()}");
// Re-fill the first name
firstNameInput = driver.FindElements(By.CssSelector($"input.form-control[id*='Child{childNumber}_txtChildFName']"))
.FirstOrDefault(el => el.Displayed)
?? throw new InvalidOperationException($"Child {childNumber} First Name input was not found after validation.");
WebElementHelper.SetInputValue(driver, firstNameInput, originalFirstName, $"Child {childNumber} First Name (restore)", triggerBlur: true);
_output.WriteLine($"[INFO] Restored First Name for Child {childNumber}: {originalFirstName}");
_output.WriteLine($"[PASS] First Name blank validation test completed for Child {childNumber}");
}
Contributor
Author
There was a problem hiding this comment.
Oops copied a bit much
protected void TestRelationshipOtherSpecify(IPookieWebDriver driver, int childNumber)
{
_output.WriteLine($"\n[INFO] Testing Relationship to PC1 'Other' validation for Child {childNumber}");
// Select "Other" (09) in Relationship to PC1
var relationshipDropdown = driver.FindElements(By.CssSelector($"select.form-control[id*='Child{childNumber}_ddlRelation2PC1']"))
.FirstOrDefault(el => el.Displayed)
?? throw new InvalidOperationException($"Child {childNumber} Relationship dropdown was not found.");
var relationshipSelect = new SelectElement(relationshipDropdown);
relationshipSelect.SelectByValue("09"); // Select "Other"
driver.WaitForUpdatePanel(3);
driver.WaitForReady(3);
Thread.Sleep(500);
_output.WriteLine($"[INFO] Selected 'Other' in Relationship to PC1 for Child {childNumber}");
// Verify specify field appears
var specifyDiv = driver.FindElements(By.CssSelector($"div[id*='Child{childNumber}_divRelation2PC1Specify']"))
.FirstOrDefault();
Assert.NotNull(specifyDiv);
Assert.True(specifyDiv.Displayed, $"Relationship specify field should be visible for Child {childNumber}");
_output.WriteLine($"[PASS] Relationship specify field appeared for Child {childNumber}");
// Clear the specify field if it has any value
var specifyInput = specifyDiv.FindElements(By.CssSelector($"input[id*='Child{childNumber}_txtRelation2PC1Specify']"))
.FirstOrDefault();
if (specifyInput != null && specifyInput.Displayed)
{
specifyInput.Clear();
_output.WriteLine($"[INFO] Cleared Relationship specify field for Child {childNumber}");
}
// Submit without filling specify field
var submitButton = FindSubmitButton(driver);
CommonTestHelper.ClickElement(driver, submitButton);
driver.WaitForUpdatePanel(30);
driver.WaitForReady(30);
Thread.Sleep(1000);
_output.WriteLine($"[INFO] Clicked Submit with empty Relationship specify for Child {childNumber}");
// Switch back to Family/Children tab (may reset to PC1)
ActivateTab(driver, "#tab_CHILDREN a[href='#CHILDREN']", "Family/Other Children");
Thread.Sleep(500);
// Verify validation message
var validationMessage = FindValidationMessage(driver, $"Child{childNumber} Relationship specify validation",
$"Please specify Child{childNumber} relationship to PC 1");
Assert.NotNull(validationMessage);
_output.WriteLine($"[PASS] Validation displayed for Child {childNumber}: {validationMessage!.Text.Trim()}");
// Change to a non-Other option
relationshipDropdown = driver.FindElements(By.CssSelector($"select.form-control[id*='Child{childNumber}_ddlRelation2PC1']"))
.FirstOrDefault(el => el.Displayed)
?? throw new InvalidOperationException($"Child {childNumber} Relationship dropdown was not found after validation.");
relationshipSelect = new SelectElement(relationshipDropdown);
var nonOtherOption = relationshipSelect.Options.FirstOrDefault(opt => !string.IsNullOrWhiteSpace(opt.GetAttribute("value")) && opt.GetAttribute("value") != "09");
if (nonOtherOption != null)
{
relationshipSelect.SelectByValue(nonOtherOption.GetAttribute("value"));
driver.WaitForUpdatePanel(3);
driver.WaitForReady(3);
Thread.Sleep(500);
_output.WriteLine($"[INFO] Changed Relationship to non-Other option for Child {childNumber}: {nonOtherOption.Text.Trim()}");
}
// Verify specify field hides
Thread.Sleep(500);
specifyDiv = driver.FindElements(By.CssSelector($"div[id*='Child{childNumber}_divRelation2PC1Specify']"))
.FirstOrDefault();
var isHidden = specifyDiv == null || !specifyDiv.Displayed || specifyDiv.GetAttribute("style").Contains("display: none");
Assert.True(isHidden, $"Relationship specify field should be hidden for Child {childNumber}");
_output.WriteLine($"[PASS] Relationship specify field hidden after selecting non-Other option for Child {childNumber}");
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.