星期三, 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

[nodejs] ER_TRUNCATED_WRONG_VALUE_FOR_FIELD 插入資料錯誤

ER_TRUNCATED_WRONG_VALUE_FOR_FIELD

查看mysql character set


SHOW VARIABLES WHERE Variable_name LIKE 'character_set_%' OR Variable_name LIKE 'collation%';


星期一, 4月 01, 2019

[node.js] 偷youtube影音首選 youtube-dl

需要去同步 youtube的資料到server存一份,

有在幹資料的人都會推的開源:youtube-dl
優點是去爬網頁的資料,不需使用 api key也可以使用,
也有支援oauth的功魴。

測試指令


-F 列出所有影片格式


youtube-dl https://www.youtube.com/watch?v=QKm-SOOMC4c -F


-f <格式字串|itag id > -g 列出指定的影片格式 (同事測試六小時會過期)

youtube-dl https://www.youtube.com/watch?v=QKm-SOOMC4c -f best,bestvideo ,
bestaudio -g

星期一, 3月 25, 2019

[ nodejs] invalid-apns-credentials

如發現以下錯誤就是p8的憑證忘記再上傳新開的app裡
誤以為先前測試APP上傳一次就可以一直通用XD

 "error": {
                    "code": "messaging/invalid-apns-credentials",
                    "message": "A message targeted to an iOS device could not be sent because the required APNs SSL certificate was not uploaded or has expired. Check the validity of your development and production certificates."
                }

星期二, 3月 19, 2019

[Nodejs] Use emitter.setMaxListeners() to increase limit 事件監聽超過最大限制

發現nodejs噴出了Use emitter.setMaxListeners() to increase limit 的警告,
找到stackoverflow的討論,但也有人說明是不是要把on 用once取代掉或有on被寫在for回圈裡面。

By default, a maximum of 10 listeners can be registered for any single event.
If it's your code, you can specify maxListeners via:
const emitter = new EventEmitter()
emitter.setMaxListeners(100)
// or 0 to turn off the limit
emitter.setMaxListeners(0)
But if it's not your code you can use the trick to increase the default limit globally:
require('events').EventEmitter.prototype._maxListeners = 100;
Of course you can turn off the limits but be careful:
// turn off limits by default (BE CAREFUL)
require('events').EventEmitter.prototype._maxListeners = 0;
BTW. The code should be at the very beginning of the app.
ADD: Since node 0.11 this code also works to change the default limit:
require('events').EventEmitter.defaultMaxListeners = 0

其他你感興趣的文章

Related Posts with Thumbnails