I tried posting this earlier, but it looks like it didn't take.
Thank you TanyaYatskovska for getting that back up.
Thanks tristaanogre. I haven't tested the script extension yet, but thanks for updating it. I have msxml6.0 on my machine, so I think you update should work for me. If not, I'll fiddle with it. My code seems to be a barebones version of the HTML script extension, so I'll compare them.
Anyway, for recording purposes, here's an implementation without the script extension that worked for me.
# Python
# Using a global dictionary to reference be able to reference XML stores by a friendly name
TableDict = {"MyTable1":XML.FirstTable,
"MyTable2":XML.SecondTable,
"MyTable3":XML.ThirdTable}
# TableAlias is the table on the webpage you want to turn into XML, it must has an outerHTML property
def GetTableOnScreenToXML(TableAlias):
try:
XMLdoc = Sys.OleObject["Msxml2.DOMDocument.6.0"]
TableHTML = TableAlias.outerHTML.replace("<br>",'') # the replace function is needed to delete any unclosed tags like <br>
XMLdoc.loadXML(TableHTML)
return XMLdoc
except Exception as e:
Log.Error("Error: " + str(e.args[0]))
# Take on screen report and turn put it in the XML Store
def CreateXMLCheckPoint(StoreName, TableAlias):
# StoreName = "FirstTable"
# TableAlias = Aliases.browser.Reports.Table
try:
OnScreenXML = GetTableOnScreenToXML(TableAlias)
if (XML.CreateXML(StoreName, OnScreenXML)):
Log.Message("XML Checkpoint created")
except Exception as e:
Log.Error(str(e.args[0]))
# The same GetTableOnScreenToXML() is used to get the table on screen, and then the Check() function is run to verify it matches the XML store
def ValidateTable(StoredXMLName):
# StoredXMLName refers to the XML Store of the table you want to validate
OnScreenTable = GetTableOnScreenToXML(TableAlias)
XMLCheckpoint = TableDict.get(StoredXMLName)
XMLCheckpoint.Check(OnScreenTable)
# Testing that you can validate the HTML table against the stored XML document
def TestValidateTable():
ValidateTable("MyTable1")