I have a test script for an application that adds 3 part numbers (i.e., rows) to a table displayed on the AUT web page. Each row in the table also contains anHTMLInputButton called View Audit Trail. The purpose of the test script is to select the correct button, which then calls up theAudit Details page for the selected part number. The code used in the test script driver is as follows (the same code is used for clicking on either an action button or a hyperlink contained within a table):
case "ClickTableItem":
{
// Note: An input example would be
03-0024-0-0001:Button>View Audit Trail
string[] keys = action[key].Split(':');
string cellvalue = keys[0].CheckGlobalValue(global); // The key data identifying which table row.
string[] objtypeANDobj = keys[1].Split('>'); // Data consists of the Object Type, and the Object to be clicked.
// Identify the table... (The name of the table from outside theSwitch statement.)
HtmlTable actionTable = (HtmlTable)map.GetType().GetProperty(key.FieldName).GetValue(map, null);
// Identify the individual table cell containing the key identifier...
HtmlCell cell = new HtmlCell(actionTable);
cell.SearchProperties.Add("ClassName", "HtmlTableCell");
cell.SearchProperties.Add("InnerText", cellvalue, PropertyExpressionOperator.Contains);
UITestControlCollection tablecells = cell.FindMatchingControls();
// Set the row index...
HtmlCell myhtmlcell = (HtmlCell)tablecells[0];
int myrow = myhtmlcell.RowIndex;
string smyrow = myrow.ToString();
HtmlCell myCell = new HtmlCell(actionTable);
myCell.SearchProperties.Add("RowIndex", smyrow);
#region Click on Hyperlink
if (objtypeANDobj[0] == "Hyperlink")
{
myCell.SearchProperties.Add("FriendlyName", objtypeANDobj[1], PropertyExpressionOperator.Contains);
UITestControlCollection testclickobjects = myCell.FindMatchingControls();
UITestControl tableclickobject = testclickobjects[0];
HtmlHyperlink myClicklink = new HtmlHyperlink(tableclickobject);
Mouse.Click(myClicklink);
logger.Write(" Action", "Table Select - Row: '" + cellvalue + "': Hyperlink '" + objtypeANDobj[1] + "' selected");
}
#endregion
#region Click on Button
else if (objtypeANDobj[0] == "Button")
{
// Search child level...
UITestControlCollection testclickobjects = myCell.FindMatchingControls();
UITestControl tableclickobject = testclickobjects.Where(btnCell => btnCell.GetChildren().Any(btnChild => btnChild is HtmlInputButton && btnChild.FriendlyName == objtypeANDobj[1])).First();
HtmlInputButton myClickbtn = tableclickobject.GetChildren().Where(btnChild => btnChild is HtmlInputButton).First() as HtmlInputButton;
Mouse.Click(myClickbtn);
logger.Write(" Action", "Table Select - Row: '" + cellvalue + "': Action Button '" + objtypeANDobj[1] + "' selected");
}
#endregion
break;
}
In VS2010, the correct button is always selected, and the correct audit page always appears. In VS2012, though, the correct button is always selected, but the green progress bar speeds across the screen and the test crashes, even though the message
log records the correct action. (It crashes because it can't find the verification information that the correct page was displayed, seeing as the correct page doesn't appear.) If I manually re-open the application, the table containing the added
part numbers is still displayed, and I can click on the appropriate View Audit Trail button and go to the correct audit page.
What really has me stymied, though, is that the script actually passed twice. Both times, though, either VS, the test script, or the app itself hiccupped, and only added 2 of the 3 part numbers to the table. As always, the correct button was
selected, but in these two cases the audit screen actually appeared, so the rest of the test passed successfully.
I've tried removing one of the part numbers, but the script still failed despite once again selecting the correct button. The first thing I thought of was re-mapping the web page objects using VS2012, but it turned out that they have the same properties
as with VS2010. Unfortunately, it didn't help. I've also tried changing the following parameters:
HtmlInputButton to HtmlButton
<PropertyCondition Name="ControlType">Button</PropertyCondition> tobtn
<PropertyCondition Name="Type">button</PropertyCondition> tosubmit
<PropertyCondition Name="Class">PageButton</PropertyCondition> toButton or btn
The only other thing unique is that the AUT for the VS2010 test script uses a different login screen than the AUT for VS2012 (different URLs for the login screens). Other than that, though, once the login screens are passed, the web pages accessed
are identical (i.e., the same URL).
Has anyone else run into a similar situation?