I have imported a excel file into eggplant and can view my data in the Variables panel in the execution screen.
How do i now compare the data in the Variables panel to data read from the SUT using OCR?
I have imported a excel file into eggplant and can view my data in the Variables panel in the execution screen.
How do i now compare the data in the Variables panel to data read from the SUT using OCR?
Depends exactly how you want to compare it. Probably an assert statement.
put ReadText(TopLeftCoordinates,BottomRightCoordinates) into MyFoundText
assert that MyFoundText = MyExcelData with warning
or
assert that ReadText(TopLeftCoordinates,BottomRightCoordinates) = MyExcelData with error
Or use if statements if you want more complex stuff to happen based on the results.
Thank you Logan.
The data is spread across multiple sheets.
How do i point the data in the spreadsheet to the data on the SUT for that particular sheet and row/column.
would your answer above cover that?
Column A has all the headings and the rest have data i want to compare to the SUT one by one and yes with assert statement either error or false etc.
Compare DummySheet1
Hostname: dummy01-block01 (Column B Row 4) with the SUT and report back a false or error
Some reorganization of your worksheet will make life a lot easier for you, but it is not absolutely necessary. I would suggest separating the two tables into two worksheets. Or just have more columns if you like. And I would transpose all of the data. The point is that EPF will read the worksheet as an actual table and you can reference the columns and rows by name just like you would a sql table (or whatever).
Something that looked like this would probably be easier to work with:
Hostname | Manufacturer | Model | Local Storage Present | Local Storage Type |
---|---|---|---|---|
dummy01-block01 | Dell | Dell Model | Yes | HDD |
dummy02-block01 | Lenovo | Lenovo Model | No | SSD |
dummy03-block01 | HP | HP Model | Yes | SSD |
set myExcelDB to {type:"Excel", file:(ResourcePath("Test.xlsx")), name: "DummySheet1"}
put the records of myExcelDb into Configurations
//log Configurations
repeat with each item Host of Configurations
if Host.Hostname = "dummy01-block01"
then
put "Looking for"&&Host.Hostname&&"attributes."
//Determine how you are going to find the searchrectangle for each attribute here:
put [topleft of "image1",bottomright of "image2"] into MySearchRectangle
//Manufacturer
put "Manufacturer:"&&Host.Manufacturer
assert that ReadText(MySearchRectangle) = Host.Manufacturer with error
//Model
put "Model:"&&Host.Model
assert that ReadText(MySearchRectangle) = Host.Model with error
//Local Storage Present
put "Local Storage Present:"&&Host."Local Storage Present"
assert that ReadText(MySearchRectangle) = Host."Local Storage Present" with error
//Local Storage Type
put "Local Storage Type:"&&Host."Local Storage Type"
assert that ReadText(MySearchRectangle) = Host."Local Storage Type" with error
end if
end repeat
You could probably also find a handy way to place your hostname into a variable so you wouldn’t have to have a script set for each one, and then you wouldn’t have to know them in advance. But start small and work your way up to that. Try turning one or more parts of this into a Handler too.
If you really don’t want to format your spreadsheets into proper tables you CAN reference them by absolute coordinates. That’s explained pretty well in the documentation here:
https://docs.eggplantsoftware.com/ePF/SenseTalk/stk-excel-file-interaction.htm#working-excel-st
It’ll make your life miserable though if that spreadsheet ever changes/gets updated.
Here’s the log with the asserts commented out:
1/14/22, 11:12:41 AM START Running Selection from Scratch_Logan/SCRATCHWork.script
>>> 11:12:41 Start handler 1: scratch_logan_scratchwork
set myExcelDB to {type:"Excel", file:(ResourcePath("Test.xlsx")), name: "DummySheet1"}
put the records of myExcelDb into Configurations
repeat with each item Host of Configurations
if Host.Hostname = "dummy01-block01"
put "Looking for"&&Host.Hostname&&"attributes."
Looking for dummy01-block01 attributes.
put "Manufacturer:"&&Host.Manufacturer
Manufacturer: Dell
put "Model:"&&Host.Model
Model: Dell Model
put "Local Storage Present:"&&Host."Local Storage Present"
Local Storage Present: Yes
put "Local Storage Type:"&&Host."Local Storage Type"
Local Storage Type: HDD
end repeat
if Host.Hostname = "dummy01-block01"
end repeat
if Host.Hostname = "dummy01-block01"
end repeat
<<< 11:12:41 End handler 1: scratch_logan_scratchwork (normal exit)
Selection Executed in 0:00:00
Thanks Logan, i have managed to absorb the speadsheet data into eggplant using the following.
set Dummysheet1_tab to worksheet (excelfile, "DummySheet1")
put 0 into spreadsheet_multiple
set cellrange to "B".."Z"
repeat forever
put (spreadsheet_multiple*22) into cell_number
put Dummysheet1_tab.cell("B"&(2+cell_number)) into host_name
repeat for each item in cellrange
put Dummysheet1_tab.cell(it&(4+cell_number)) into host_name
if host_name is empty
put "yes" into horizontal_done
exit repeat
end if
put 0 into cell_amount
put "no" into horizontal_done
repeat 19 times
put Dummysheet1_tab.cell(its&(5+cell_number+cell_count)) into global structure.(DummySheet1").(cluster_name).(host.name).(Dummysheet1_tab.cell("A"&(5+cell_number+cell_count)))
add 1 to cell_count
end repeat
end repeat
add 1 to spreadsheet_multiple
put (spreadsheet_multiple*22) into cell_number
put Dummysheet1_tab.cell("B"&(4+cell_number)) into host_name
if host_name is empty
exit repeat
end if
end repeat
Still having issues comparing this data (spreadsheet) with the SUT (which is a VMware virtualization platform). Apologies for the back and fourth as I’m fairly new to eggplant.
e.g. Speadsheet in eggplant : Hostname - dummy01-block01
matches or doesn’t (True/False) match the SUT VMware virtualization platform.
i am looking into getting a data dump of the VMware virtualization platform, so potentially doing a comparison with a excel sheet. At the moment that is unavailable so having to compare to the SUT.