顯示具有 sensetalk 標籤的文章。 顯示所有文章
顯示具有 sensetalk 標籤的文章。 顯示所有文章

星期三, 8月 25, 2021

[Eggplant Functional] SenseTalk: 將Excel透過Database的方式來操作

除了透過檔案的方式來操作Excel,也可以將Excel透過Database的形式來操作。

個人更覺得更好操作。

以下範別就是想要把測試案例的結果另外存到一份Excel,這樣long testing就可以比較好撈資料




//連線Excel,開啟唯讀模式 

set myExcelDB to {type:"excel", file:excelPath, writable: Yes}

//sheet nametable name

put table worksheet of myExcelDB into sheetTable


//建立要寫入的物件


put the date into currentDateObj

put {TEST_CASE:testcase, DATA_JSON:valueWithJSONString,DATE:currentDateObj} into testresult

//寫入一列

add record testresult to table worksheet of myExcelDB 


Working with Excel as a Database

星期六, 8月 07, 2021

[Eggplant] SenseTalk JSON資料操作

JSON已經是普遍的資料交換標準,可以簡單跟不同程式間作為溝通的橋樑。

SenseTalk提供JSONFormat/JSONValue二個方法來讓用戶使用

JSONValue

將json string轉換到json object於sensetalk使用

PS:要注意json字串要有雙引號,否則會解析錯誤

MockDataFromExcel "PM","ETS_PM_0008"

put the result into mockTicket

log mockTicket

put JSONValue(mockTicket) into ticketInfoWithJSON

log ticketInfoWithJSON's reserveNo



2021/8/8, 2:36:12 PM Log {"carType":"標準車廂", "count":"1", "date":"2021/07/30", "depature":"14:46", "end":"台中", "full":1, "fullSubTotal":"700", "no":"651", "reserveNo":"06264014", "seat":"window", "start":"台北", "subTotal":"TWD 700", "trainTimeType":">60", "type":"單程"}

2021/8/8, 2:36:12 PM Log 06264014


JSONFormat

put JSONFormat(ticketInfoWithJSON) into ticketInfoWithJSONString

log ticketInfoWithJSONString

當然也可以在把json object轉回string回存,中文也可以正常編碼

2021/8/8, 2:36:17 PM Log {

  "carType": "\u6a19\u6e96\u8eca\u5ec2",

  "count": "1",

  "date": "2021/07/30",

  "depature": "14:46",

  "end": "\u53f0\u4e2d",

  "full": 1,

  "fullSubTotal": "700",

  "no": "651",

  "reserveNo": "06264014",

  "seat": "window",

  "start": "\u53f0\u5317",

  "subTotal": "TWD 700",

  "trainTimeType": ">60",

  "type": "\u55ae\u7a0b"

}

其他你感興趣的文章

Related Posts with Thumbnails