メインコンテンツまでスキップ

Eggplant Functionalでのデータテーブルの検証

データテーブルは、多くのデスクトップ、Web、一部のモバイルアプリケーションの共通のコンポーネントです。全ての業界で、病院の患者リスト、財務データ、オープンな求人情報などを表示するために何らかの形でデータテーブルを活用するソフトウェアが使用されています。

データテーブルに関連する一般的なユースケースには、アプリケーションのUIに表示されるデータテーブルの内容が基礎となるデータベースの内容を反映していることを検証すること、またはフォームに提出されたレコードが継続し、後でアプリケーションのデータテーブルに表示されることを検証することが含まれます。Eggplant Functionalのテスト自動化ツールを使ったデータテーブルの検証は強力であり、SenseTalkの高度なスクリプティングとデータベースアクセス能力を活用します。

データテーブル検証の実際

以下のビデオは、Eggplant Functionalが異なるデータテーブルの異なる側面を検証する例を示しています。

テクトーク

以下のSenseTalkコマンド、関数、変数、構文は、データテーブルの検証で使用され、上記のビデオで参照されています。

readText() Function
readTable() Function
imageRectangle() Function
foundImageInfo() Function
remoteClipboard() Function
Local Variables
* Repeat Loops
Arithmetic Commands
Property Lists
Conditional Statements
Points and Rectangles
Messages
Chunk Syntax and Working with Chunks
* Working with Databases

データテーブル検証のためのスクリプト

以下のスクリプトは、テーブルの検証に使用できます。

レコード比較スクリプト: このスクリプトは、データベースと表示されているデータテーブルから全てのデータ行を取得し、その内容を比較します。

//このスクリプトは、RetrieveRecordsスクリプトに保存されている関数を活用します

put RetrieveRecords.fromUI into ActualRecords
log "実際のレコードは次の通りです:"
LogAllRecords ActualRecords

log "-------------------------------------------------------"

put RetrieveRecords.fromDB into ExpectedRecords
log "期待されるレコードは次の通りです:"
LogAllRecords ExpectedRecords

If ActualRecords = ExpectedRecords
LogSuccess "レコードセットは一致します。"
else
LogError "レコードセットは一致しません。"
End If

If item 5 of ActualRecords = item 5 of ExpectedRecords
put item 5 of ActualRecords
put item 5 of ExpectedRecords
LogSuccess "5番目のレコードは一致します。"
End If

on LogAllRecords RecordList
repeat with each item of RecordList
Log it
end repeat
end LogAllRecords

レコード取得スクリプト:

このスクリプトは、テーブルから個々のレコードを取得します。

function fromUI
//この関数は、画面上のView要素を使ってテーブルの各行のデータを識別します。
put everyImageRectangle ("ViewIdentifier") into Rows
put imageRectangle ("ItemIDColumn") into ItemIDLoc
put imageRectangle ("NameColumn") into NameLoc
put imageRectangle ("ProductLineIDColumn") into ProductLineIDLoc

repeat with each Row of Rows
set theTop to Row's top
set theBottom to Row's bottom
put readText (ItemIDLoc's left,theTop,NameLoc's left,theBottom) into theItemID
put readText (NameLoc's left,theTop,ProductLineIDLoc's left,theBottom) into theName
insert (ItemID:theItemID,Name:theName) into TableRead
end repeat

return TableRead
end fromUI

function fromDB
set myDB to (type:"odbc", DSN:"mySQLDB", user:"root", password:"eggPlant")
put table "table_demo_data2" of myDB into myDBTable
return the records of myDBTable
end fromDB

すべて含むスクリプト: このスクリプトは、情報のセットがリスト内に含まれているかどうかを確認する方法を示しています。

put ((food:"Grilled Cheese",drink:"milk"),(food:"Hamburger",drink:"soda")) into ActualRecords
put ((food:"Hamburger",drink:"soda"),(food:"Grilled Cheese",drink:"lemonade")) into ExpectedRecords

repeat with each myRecord of ExpectedRecords
Assert that ActualRecords contains myRecord with warning
end repeat

フルテーブル読取りスクリプト: このスクリプトは、各データ行に識別子がない場合にデータテーブルのすべての行のデータを読み取ります。

put imageRectangle ("SymbolColumn") into SymbolColumnLoc
put foundImageInfo()'s imageLocation into StartLoc
put imageRectangle ("NameColumn") into NameColumnLoc
put imageRectangle ("PriceColumn") into PriceColumnLoc
put (StartLoc,(SymbolColumnLoc's right,StartLoc's y + 42)) into SymbolRead
put ((NameColumnLoc's left, StartLoc's y),(NameColumnLoc's right,StartLoc's y + 42)) into NameRead
put ((PriceColumnLoc's left, StartLoc's y),(PriceColumnLoc's right,StartLoc's y + 42)) into PriceRead
repeat until endofTable is true
put readtext(SymbolRead) into Symbol
if Symbol is empty then
set endofTable to true
exit repeat
end if
put readtext(NameRead) into Name
put readtext(PriceRead) into Price
add ((0,45),(0,45)) to SymbolRead
add ((0,45),(0,45)) to NameRead
add ((0,45),(0,45)) to PriceRead
insert (Symbol:Symbol, Name:Name, Price:Price) after TableRead
end repeat

Log "テーブルのレコードは:"
Log TableRead

隣接エントリを読取るスクリプト: このスクリプトは、検索長方形内で期待値を検索し、見つかった期待値の隣接する内容を検証します。

Set the searchRectangle to ("FIRSTColumn",(imageLocation("LASTColumn")'s x, the remotescreensize's y))

repeat until imageFound (text:"EG629610")
MoveTo the remoteScreenRectangle's center
ScrollWheelDown 4
end repeat

set the searchRectangle to ()

put foundImageInfo()'s imageRectangle into RowLoc
put imageRectangle ("LASTColumn") into LASTColumnLoc

put (LASTColumnLoc's left, RowLoc's Top - 20, imageLocation("DOBColumn")'s x, RowLoc's Bottom + 20) into LastNameReadArea

Assert that readText(LastNameReadArea) is "DemoCardio"

エントリ検索スクリプト: このスクリプトは、検索長方形内で期待値を検索します。

put readText ("RecordNumberUL","RecordNumberLR") into PatientPRN

Set the searchRectangle to ("FIRSTColumn",(imageLocation("LASTColumn")'s x, the remotescreensize's y))

WaitFor 10, text:PatientPRN

リモートクリップボードスクリプト: このスクリプトは、クリップボードを使用して、データテーブルの特定の行の特定の列からデータ値を取得します。

imageRectangle ("GasolinePerGallonColumn")をGasolineLocに入れる
imageLocation(image:"UnitedStatesColumn",searchRectangle:(GasolineLoc's topLeft,(GasolineLoc's right, the remoteScreenSize's height)))をColumnLocに入れる

DoubleClick (ColumnLoc's x,imageLocation ("MayRow")'s y)

TypeText ControlKey,"c"

remoteClipBoardをDollarValueに入れる
Log "The scraped value is"&&DollarValue&period

If DollarValueは2.000より大きい場合
LogSuccess "The value is greater than 2 dollars."
else
LogWarning "The value is equal to or less than 2 dollars."
End If

スクロールして抽出スクリプト: このスクリプトは、データテーブルをスクロールし続け、各ページのデータ行を取得し保存します。

imageRectangle ("RowNumColumn")をRowLocに入れる
foundImageInfo()'s imageLocationをStartUpperLeftに入れる
imageRectangle ("ScrollProgressColumn")をScrollLocに入れる

(StartUpperLeft,(RowLoc's right,StartUpperLeft's y + 38))をRowReadに入れる
((ScrollLoc's left, StartUpperLeft's y),(ScrollLoc's right,StartUpperLeft's y + 38))をScrollReadに入れる

Recordsのアイテム数が50を超えるまで繰り返す
EndReachedをfalseに設定
EndReachedがtrueになるまで繰り返す
readText(RowRead)をRowValueに入れる
if RowValueが空ならば
EndReachedをtrueに設定
exit repeat
end if
readText(ScrollRead)をScrollValueに入れる
(RowNumber:RowValue,ScrollProgressPercent:ScrollValue)をRecordsに挿入
((0,37),(0,37))をRowReadに追加
((0,37),(0,37))をScrollReadに追加
end repeat
TypeText PageDown
wait 3
Recordsの最後のアイテムをLastReadRecordに入れる
LastReadRecord's ScrollProgressPercentをLastReadPercentに入れる
imageRectangle (text:LastReadPercent)'s bottomをLastLocYに入れる
((RowLoc's left,LastLocY + 14),(RowLoc's right,LastLocY + 51))をRowReadに入れる
((ScrollLoc's left, LastLocY + 14),(ScrollLoc's right,LastLocY + 51))をScrollReadに入れる
end repeat

log records

レコード検証スクリプト: このスクリプトは、光学文字認識(OCR)を使用して、データベーステーブルに保存されているすべての値に対して表示されるデータテーブルを検索します。

myDBを(type:"odbc", DSN:"mySQLDB", user:"root", password:"eggPlant")に設定
myDBのtable "table_demo_data"をmyDBTableに入れる
myDBTableのレコードをmyDBDataに入れる

searchRectangleを("TableUL","TableLR")に設定
myDBDataの各myRecordで繰り返す
WaitFor 5, text:myRecord's Time
WaitFor 5, text:myRecord's Gene_Copies
end repeat