That sounds like a good idea. Thanks for the script extension, I'll give it a shot. In the mean time, here's the basic form of the code I wrote.
The basic workflow is like this:
1. Take the on-screen table and covert it to an XML doc
2. Then either store it as a Checkpoint or compare it to a checkpoint.
This is the solution I wrote in Python. It is currently hardcoded to look for a specific table, but it can be expanded on to allow passing in any HTML table that is mapped as an Alias, or found using FindChild or something.
# Converts an HTML Table to an XML doc
# Used for creating XML checkpoints of tables AND validating tables against checkpoints
def OnScreenTableToXML():
try:
# Using MSxml 6.0 on my machine. Some people may need to use 3.0
XMLdoc = Sys.OleObject["Msxml2.DOMDocument.6.0"]
HTMLTable = Aliases.tableTable.outerHTML.replace("<br>",'') # Replace is used to fix any unclosed tags in the HTML. Can't create an XML doc with unclosed tags like <br>
XMLdoc.loadXML(HTMLTable)
return XMLdoc
except Exception as e:
Log.Error("Error: " + str(e.args[0]))
# This example is used read the on-screen Table and
# stores it as an XML Checkpoint for future use.
# After running this, the new checkpoint will show up under Stores > XML in the Project Explorer.
def CreateXMLCheckPoint():
StoreName = "MyFirstTable"
try:
OnScreenXML = OnScreenTableToXML()
if (XML.CreateXML(StoreName, OnScreenXML)):
Log.Message("XML Checkpoint created")
except Exception as e:
Log.Error(str(e.args[0]))
# I created a dictionary to map simple names to the XML Stores
# This is stored outside of any function and is globally available to functions in the script
TableDict = {"TableOne":XML.MyFirstTable,
"TableTwo":XML.MySecondTable,
"TableThree":XML.MyThirdTable}
# After a checkpoint as been created for MyFirstTable, we can use this to validate an on screen table against the Store
def ValidateTable():
TableName = "MyFirstTable"
OnScreenTable = OnScreenTableToXML()
XMLCheckpoint = TableDict.get(TableName)
XMLCheckpoint.Check(OnScreenTable)