星期三, 4月 29, 2020

直接開啟Xcode的模擬器

很多時候需要開模擬器來測試客戶用不同裝置的瀏覽狀況,
這時候可以從cmdline直接下以下指令比較方便

open -a Simulator.app

星期四, 4月 23, 2020

[Eggplant] 透過命令行的runscript指令來執行suite的測試

在透過EPF撰寫完相關的suite後,在不同主機上執行suite,就不用再開EPF了。
只要透過runscript指令即可呼叫。

首先先安裝runscript指令(這樣就免除需要執行完整的路徑)


Important: For Mac installations of Eggplant Functional version 18.0 and later, the path to call the runscript command has changed to /Applications/Eggplant.app/Contents/MacOS/runscript

Eggplat->Perference->Run,接著按install runscript in /usr/local/bin即可


[Eggplant] 使用shell指令執行Java Jar

測試如何shell執行java包出的jar檔應用,並把執行結果取出。

測試一般jar檔執行

MacBook-Pro-8:eggplant_cmd bigd$ java -cp JarDemo.jar com.test.jardemo.TestJar "Hello World" "Ken"

輸入參數0:Hello World

輸入參數1:Ken


//存放shell輸出的東西
set destinationFile to "/Users/bigd/Downloads/shellOutput.txt"

//Users/bigd/Downloads/eggplant_cmd
shell "java -cp /Users/bigd/Downloads/eggplant_cmd/JarDemo.jar com.test.jardemo.TestJar 'Hello World' 'Ken' >"  & destinationFile

put file destinationFile into shellOutput
//LogSuccess file destinationFile
log shellOutput

//砍掉檔案
delete file destinationFile



參考

星期六, 2月 15, 2020

[Vscode] Beautify 如何自訂快捷鍵

剛裝了vscode,寫前端立馬找了Beautify套件。
但為了設快捷鍵找了一會,順便筆記一下

我用的是mac的vscode,以下記錄一下自訂流程

星期三, 1月 08, 2020

[Eggplant] shell cmd 執行window batch

簡單的呼叫bat檔的測試案例,並可將bat的執行結果輸出在txt檔上

(*
http://docs.testplant.com/ePF/SenseTalk/stk-system-interaction.htm#shell
*)

//set the shellCommand to "ShellExecute"

//run bat 
shell "c:\windows\system32\cmd.exe", <
> ">C:\Users\bigd\Downloads\ShellOutpoutFile.txt"

//read bat result from output file
put file "C:\Users\bigd\Downloads\ShellOutpoutFile.txt" into ShellLog

//print outputfile info
log "Shell content from TxtFile"

log ShellLog

http://docs.testplant.com/ePF/SenseTalk/stk-system-interaction.htm

[Eggplant] 【進階範例】SUT斷線重新連結

星期二, 1月 07, 2020

[Eggplant] Android Gateway | android rotate指令


--force-rotForces SN2 to rotate the image. Prior to Android 6.0, the image that came from Android OS to SN2 was not rotated, and SN2 had to rotate it, so it would appeared readable in Eggplant Functional. In Android 6.0 and later, SN2 receives an already rotated image. This option forces SN2 to rotate images even on Android 6.0 and later. This option is implemented in case some devices do not have this updated behavior.
--screen-rot 0
--screen-rot 1
--screen-rot 2
--screen-rot 3
Turns the screen by 0, 90, 180, or 270 degrees, respectively.

http://docs.testplant.com/ePF/using/epf-android-gateway-options.htm

[Eggplant] 跨平台裝置測試如何提升圖片搜尋率

跨平台裝置常會測試案例的圖相(例如按鈕大小)遇到不同解析度會有放大的問題?
可以透過以下方法,就不需要依據每個SUT受測裝置擷過過多圖片。


1. Search Type設成Adaptive To Image

2.  設定Scale Factor去比對不同解析度的圖像=>可先透過測試指定比例

 2.1  可在EPF settings裡面設定參數

 2.2 程式控制
//愈細則會增加搜尋時間
set the scaleFactors to 0.5 to 1 step 0.01

更多scaleFactors設定可參考以下連結
http://docs.testplant.com/ePF/SenseTalk/stk-eggplant-functional-global-properties.htm


3. 調Image設定的Tolerance

備註:如何打開hidden的圖像識別
Show all search types

[Eggplant] 客戶問題:Windows手動安裝selenium伺服器與Java環境

先前在客戶端安裝eggplant官方的window selenium安裝包
發現在執行webdrive指令會發生異常的錯誤,
發現手動重新安裝就可以解決這個問題。



Java環境設定

下載JRE
https://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html

安裝完後會在此目錄下看到執行的java.exe
C:\Program Files\Java\jre1.8.0_231\bin

接著設定環境變數,才有辦法直接在cmdline的路徑下都打java指令

星期一, 1月 06, 2020

[Eggplant] 客戶問題: Number of Errors logged: 183

有趣的客戶案例:
將多個測試腳本拆開後,再分開使用run指令呼叫各部份的測試腳本,
因在單自的腳本裡有寫LogError來印LOG,
就會造成此錯誤訊息Number of Errors logged
造成最外層想要做一個long run的廻圈無法正確執行。
解決方法將LogError改成LogWarning即可,
因使用LogError如發生錯誤不會在中間的腳本停掉程序的



補充:

Run:可以用在順序的腳本執行,簡單來說就是每一個腳本中間是有相關聯的,
因此異常就會中斷整個測試集

RunWithNewResult: 就不會因其中一個錯誤腳本而中斷。


星期一, 11月 11, 2019

[Eggplant] 【進階語法】ScreenPart提昇你的OCR的辨識速度

等你熟悉了eggplant的圖片/OCR識別的使用後,
如果想要再提昇速度,可以在每次搜尋目標時,
定義搜尋的區塊(searchRectangle )
可以加速整個Script的執行

定義ScreenPart函數

請在你的suite裡新增一個script,命名為ScreenPart檔名,接著貼以下的程式碼

[Eggplant] 使用eggplant functional連結Selenium進行自動化測試(三):取得網頁Table的數值,以wiki百科為例

主要使用Selenium來讀取表格的內容,
進行自動化測試會比使用圖片識別更來的單純,
這個範例是分析wiki百科內的這個表格。



取得元素WebElement Identifiers

類似jquery的選擇器,提供多種方法讓你找到網頁上的元素

元素物件WebElement Objects

當找到元素後你會獲得一個WebElement物件,可以協助你萃取元素的資訊

待補...

[Eggplant] 使用eggplant functional連結Selenium進行自動化測試: 安裝於windows

如果有參考先前mac的教學做過一遍的話,
那使用window的客戶就更單純了~真是幸福呀!箊
只要到eggplant下載官方的WebDriverServerSetup.exe安裝包(安裝精靈),
一步接一步就會安裝完,Selenium Server了,不過WebDriver也是要另外下載(參考先前的文章)。

下載資訊

https://www.eggplantsoftware.com/eggplant-functional-downloads

懶到到官網下載頁面的話請至以下連結
http://downloads.testplant.com/downloads/WebDriverServerSetup.exe

安裝完後要啟動在windows的選單就可以發現啦:D

星期日, 11月 03, 2019

[Eggplant] 使用eggplant functional連結Selenium進行自動化測試(二):建立連線

繼上一篇架設環境後,我逐一來說明如何建立連線。
PS:此文章內容已包含所需的環境建置

啟動你的Selenium Server

如已啟動可以忽略此步驟

 selenium-server -port 4444

建立一個新的連線

打開eggplant functional且打開connection list
這個連線就是連接你電腦安裝的selenium,
預設的port為4444,
Connection Type請選擇為WebDriver


[Eggplant] 使用eggplant functional連結Selenium進行自動化測試(一):安裝 mac測試環境

本文以Mac開發環境來記錄整個安裝Selenium WebDriver Testing流程。

系統限制

Note: Eggplant Functional works with Selenium Server 2.0, also known as Selenium WebDriver. Supported browsers are Firefox, Google Chrome, Microsoft Edge, Microsoft Internet Explorer 10, and Safari. Typically, you need to install a driver for each browser type you want to use.

要注意非windows環境要額外裝自已要的WebDriver

運作方式

SenseTalk <==> Selenium Server <==> Browser Drivers <==> Web Page


前置環境建置

安裝homebrew

進入/usr/bin目錄安裝homebrew

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"


星期二, 8月 13, 2019

[node.js] passport.js OAuth2 api的社群整合

記錄一下撰寫node.js的restful api串接社群按鈕。
基本上流程因前端是react app,
所以會使用前端的fb/google sdk來取得access token,
再提供restful api來驗證access token,
成功後就可以取得Oauth的用戶資訊,
接著就是自已server 用戶資料,如何連結社群的邏輯。

node.js套件

https://github.com/jaredhanson/passport-facebook
https://github.com/jaredhanson/passport-facebook-token
https://github.com/jaredhanson/passport-google-oauth2https://github.com/davidep87/passport-token-google
https://github.com/jmreyes/passport-google-id-token (暫時沒使用)

星期二, 6月 18, 2019

[ nodejs] InAPP購物串接

記錄一下App自動串接流程

Apple In-App流程




驗證的狀態碼

Status Code
Description
21000
The App Store could not read the JSON object you provided.
21002
The data in the receipt-data property was malformed or missing.
21003
The receipt could not be authenticated.
21004
The shared secret you provided does not match the shared secret on file for your account.

21005
The receipt server is not currently available.
21006
This receipt is valid but the subscription has expired. When this status code is returned to your server, the receipt data is also decoded and returned as part of the response.
Only returned for iOS 6 style transaction receipts for auto-renewable subscriptions.
21007
This receipt is from the test environment, but it was sent to the production environment for verification. Send it to the test environment instead.
21008
This receipt is from the production environment, but it was sent to the test environment for verification. Send it to the production environment instead.
21010
This receipt could not be authorized. Treat this the same as if a purchase was never made.
21100-21199
Internal data access error.

Apple自動訂閱通知


可以自訂api讓apple傳送自動訂閱資訊




Google In-APP流程

申請服務帳號

在Google Play Console的 API 存取權,新增一個服務帳戶,並指定財經的角色權限
https://codeday.me/bug/20180810/215717.html

OAuth驗證


Receipt驗證API

https://www.googleapis.com/androidpublisher/v3/applications/{{GOOGLE_PUBLISHER_PACKAGE_NAME}}/purchases/subscriptions/{{GOOGLE_PUBLISHER_SUB_ID}}/token
s/{{GOOGLE_PUBLISHER_TOKEN}}

GOOGLE_PUBLISHER_PACKAGE_NAME
GOOGLE_PUBLISHER_SUB_ID
GOOGLE_PUBLISHER_TOKEN

Receipt訂閱資訊


{"packageName":"com.rex.billingtest","acknowledged":false,"orderId":"transactionId.android.test.purchased","productId":"android.test.purchased","developerPayload":"","purchaseTime":0,"purchaseState":0,"purchaseToken":"inapp:com.rex.billingtest:android.test.purchased"}


{"orderId":"GPA.3380-9023-5860-65305","packageName":"com.cupola.cupola360","productId":"sub_month_01","purchaseTime":1562753803599,"purchaseState":0,"purchaseToken":"opbbhlabpbpjdeombpgnadel.AO-J1OzUpM2j8a3jxX5DjbjfI0_Z6iAfKs7kWuC5Ssq24UI5pEPflxurbEdlRK_bWgr5fKnFDyVCqmCGThyRR-fSSsqcT-sJrWSMzVcGavjHmh3to2mO5hIkj-WKqSFqdAYLJmhKGANg","autoRenewing":true}


參考資料

https://cg2010studio.com/2018/05/24/ios-iap-%E9%A9%97%E8%AD%89%E7%99%BC%E7%A5%A8-iap-verify-receipt/

https://www.cnblogs.com/shycie/p/5499186.html

https://alexdisler.com/2016/03/20/validating-cordova-in-app-purchases-on-ios-and-android-using-nodejs/

https://www.appcoda.com.tw/in-app-purchase-tutorial/

https://cheesecakelabs.com/blog/google-play-iap-first-setup-test-sandbox/

https://codeday.me/bug/20180810/215717.html


官方Apple
https://developer.apple.com/library/archive/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html

https://developer.apple.com/library/archive/releasenotes/General/ValidateAppStoreReceipt/Chapters/ReceiptFields.html

https://developer.apple.com/documentation/storekit/in-app_purchase/enabling_status_update_notifications

https://help.apple.com/app-store-connect/#/dev0067a330b

官方GooglePlay
https://developer.android.com/google/play/billing/billing_overview.html
https://github.com/googleapis/google-api-nodejs-client#service-to-service-authentication
https://alexdisler.com/2016/03/20/validating-cordova-in-app-purchases-on-ios-and-android-using-nodejs/


星期五, 4月 19, 2019

[nodejs] ONLY_FULL_GROUP_BY

MySQL5.7後將sql_mode的ONLY_FULL_GROUP_BY模式預設設定為開啟狀態,這樣一來,很多之前的sql語句可能會出現錯誤,錯誤資訊如下:

查看

select @@global.sql_mode

完整的mysql.cnf覆寫(安裝環境為ubuntu)

sudo vim /etc/mysql/my.cnf (為/etc/mysql/mysql.cnf的軟連結)

[mysqld]
sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'

之後重啟(設定檔如果打錯,mysql會無法開啟,請小心)
sudo service mysql restart

其他你感興趣的文章

Related Posts with Thumbnails