Forum Discussion
sonya_m
SmartBear Alumni (Retired)
Here's a tip for all willing to try completing this challenge.
This is the script to start with that you can use an example to parse the Orders table and save it to a variable:
function Test()
{
var table = Sys.Browser("chrome").Page("https://www.w3schools.com/html/html_tables.asp").Panel("belowtopnav").Panel(0).Panel("main").Panel(1).Panel(0).Table("customers");
if(!Project.Variables.VariableExists("MyTable"))
Project.Variables.AddVariable("MyTable", "Table"); ParseTreeTable(Project.Variables.VariableByName("MyTable"), table); PostTableToLog(Project.Variables.VariableByName("MyTable"));
}function ParseTreeTable(TableVariable, ATable)
{
TableVariable.RowCount = ATable.RowCount;
for (var k = 0; k < ATable.ColumnCount(0); k++)
TableVariable.AddColumn(); for (var i = 0; i < ATable.RowCount; i++)
{
// Goes through cells
for (var j = 0; j < ATable.ColumnCount(i); j++)
{
// Obtains a cell
var cell = ATable.Cell(i, j); TableVariable.$set("Item",j,i, cell.innerText);
}
}
}function PostTableToLog(TableVariable)
{
Log.AppendFolder("Table");
for (var i = 0; i < TableVariable.RowCount; i++) {
Log.AppendFolder("Row " + i); // Goes through cells
for (var j = 0; j < TableVariable.ColumnCount; j++)
{
// Posts the cell's text to the log
Log.Message("Cell " + j + ": " + TableVariable.Item(j,i));
}
Log.PopLogFolder();
} Log.PopLogFolder();
}
Now, you will need to extract data from the Excel table, compare values, and replace values in the Excel file with the correct ones!
Good luck😊
sonya_m
5 years agoSmartBear Alumni (Retired)
It looks like with minor changes, the following script posted as a solution here will be the answer for this task, too:
- tristaanogre5 years agoEsteemed Contributor
*cracks knuckles* OK... I've been itching for a challenge. Stay tuned...
- sonya_m5 years agoSmartBear Alumni (Retired)
That's the spirit 💪 !
Related Content
Recent Discussions
- 2 days ago