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

星期三, 3月 06, 2019

[FCM] 如何在web端取得registration token

如何在用戶的 web client端產生網頁的registration token

https://firebase.google.com/docs/cloud-messaging/js/client#access_the_registration_token

[FCM] firebase常見q&a

  1. Do I have to unsubscribe the old token and subscribe the new token to topics?
AFAIK, you don't have to unsubscribe the old token, since it will be discarded by FCM itself. For the new token, yes, you'll have to subscribe it to the topic you need. The usual thing is done (in Android) by having subscribeToTopic() in onTokenRefreshed().

  1. Do I have to remove the old token and add the new token to device groups?
Yes. You have to handle the mapping/relationships for Device Group Messaging. See my answer here. This is different from topics. The token will be invalidated, but will be kept as part of the list of registration tokens for the corresponding registration key.
It's why there's a possibility to receive a NotRegistred error on one of the tokens if you send to Device Group. :)

  1. Is it possible to get information about device groups/topics for a token?
For Device Group Messaging (same with #2), the developer (you) have to manage these details yourself. For topics, you can use the InstanceID API. Specifically, set details parameter to true:
[optional] boolean details: set this query parameter to true to get available IID token details, including connection information and FCM or GCM topic subscription information (if any) for the device associated with this token. When not specified, defaults to false.

  1. Can I add a token to a device group more than once?
Ahmm. Yes. Do you mean the same token? If so, I haven't tried it yet. Might as well do some checking on the client side before adding.

  1. Can I subscribe a token to a topic more than once?
If you mean re-subscribing, then yes. If you mean duplicate request to subscribe, I think the result would still be a success. No changes in behavior though.

  1. Will multiple subscriptions/additions of the same token result in receiving duplicate messages?
Tested it out. You won't receive duplicate messages for both duplicate topic subscriptions and adding the same token to a device group. It seems that FCM ignores the request to subscribe/add a Registration token if it's already subscribed/added to a device group.

星期一, 2月 18, 2019

星期六, 2月 16, 2019

解決無法bitbucket.org連線的問題

記錄無法bitbucket連線的問題

Q: Could not resolve hostname bitbucket.org: Temporary failure in name resolution
A:
sudo vim /etc/resolv.conf
nameserver 8.8.8.8
search bitbucket.org
測試連線
nslookup bitbucket.org
Server: 10.211.55.1
Address: 10.211.55.1#53

Non-authoritative answer:
Name: bitbucket.org
Address: 18.205.93.2
Name: bitbucket.org
Address: 18.205.93.1
Name: bitbucket.org
Address: 18.205.93.0


星期二, 1月 29, 2019

[AWS] NODEJS SES (Simple Email Services)寄信

第一次設定ses的流程,有需要的朋友可以試試。
寄送信件有發信跟寄信需要設定。SES的操作介面都有

開始設定

1.進入SES設定
https://console.aws.amazon.com/ses/home

2. 設定domain發信


接續上步之後,就可以看到一堆dns相關資訊,這裡我是設定到cloudflare上。填完設定後就會通過domain認證


有通過認證後,就可以看到verified的綠字了


2. 測試發信

新增一個測試的信件,再去這個信箱發信,點擊驗證link。之後email才能測試寄件


接著你可以用Domain/Email Address來寄信。

Domain寄信
則可以自定要發信的email名稱,這樣就可以依不同服務寄送信件給用戶。EX:註冊信



Email Address寄信
可以用驗證過的信箱寄信給指定信箱


3.設定S3收信

可以寄信就要設定收信了,大多都會將信件存到s3上,
請至Email Receiving做規則設定

4.設定IM

沒有開就不能跟SES API整合,參考錯誤處理2

5.移出沙盒模式

沒有開就不能寄沒驗證過的信箱,參考錯誤處理3



之後就要填寫一些相關的資訊,之後就等support team回覆開通就可以串接了。
查看進度可以點以下連結

nodejs aws-sdk錯誤處理


1. Signature時間逾期
{"message":"Signature expired: 20190129T112038Z is now earlier than 20190129T131757Z

要校正機器的時間設定,因為是裝ubuntu可參考下面的
sudo apt-get install ntp ntpdate
sudo ntpdate ntp.ubuntu.com

2. 權限不足

{"message":"User `arn:aws:iam::161004446739:user/<你的帳號>' is not authorized to perform `ses:SendEmail' on resource `arn:aws:ses:us-east-1:<你的awsid>:identity/tester1@gmail.com'"

要去im設定ses的群組,才能使用

3.信箱沒有驗證

{"message":"Email address is not verified. The following identities failed the check in region US-EAST-1: bigdstut@gmail.com","stack":"MessageRejected: Email address is not verified. 
寄信的對像沒有通過驗證,預設是在沙盒模式中
https://docs.aws.amazon.com/zh_tw/ses/latest/DeveloperGuide/request-production-access.html?icmpid=docs_ses_console

參考

https://docs.aws.amazon.com/zh_tw/ses/latest/DeveloperGuide/verify-domain-procedure.html

https://docs.aws.amazon.com/zh_tw/ses/latest/DeveloperGuide/dns-txt-records.html?icmpid=docs_ses_console

https://docs.aws.amazon.com/zh_tw/ses/latest/DeveloperGuide/dkim.html

網域dkim
https://docs.aws.amazon.com/zh_tw/ses/latest/DeveloperGuide/easy-dkim-setup-domain.html

如何設定寫入s3權限
https://docs.aws.amazon.com/zh_tw/ses/latest/DeveloperGuide/receiving-email-permissions.html

寫code
https://github.com/nodemailer/nodemailer-ses-transport
https://medium.com/@yashoda.charith10/sending-emails-using-aws-ses-nodejs-460b8cc6d0d5

http://jsnwork.kiiuo.com/archives/2539/amazon-ses-%E8%A8%AD%E5%AE%9A-email%EF%BC%8C%E8%AE%93%E4%BD%BF%E7%94%A8%E8%80%85%E5%AF%84%E4%BF%A1%E4%BC%BA%E6%9C%8D%E5%99%A8%E6%94%B6%E4%BF%A1%E8%BD%89%E5%AF%84%E7%B5%A6%E7%AE%A1%E7%90%86/

星期二, 1月 15, 2019

星期六, 1月 12, 2019

[AngularJS] 1.x 動態產生表單ng-form的筆記

常常需要寫到在一個form裡面再透過ng-repeat產生多個ng-form
可以參考以下範例
http://embed.plnkr.co/Zu8CPGymfHVKt83S4SzA/preview

簡單記錄一下完成的做法,不然每次用都會忘記...

ng-form的name不需要額外透過ng-repeat的$index動態產生不一樣的流水號也可以做,
先前還有故意產生ticket.formId但其實也不需要!!




星期五, 1月 11, 2019

React.js 異常錯誤大小事

1. 確認Ref的寫法是不是沒有更新,更新就會正常了
uikit.min.js?r=0.2995152529685583:51 Uncaught Error: Minified React error #119; visit http://facebook.github.io/react/docs/error-decoder.html?invariant=119 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
    at r (uikit.min.js?r=0.2995152529685583:51)
 Object.addComponentAsRefTo 


其他你感興趣的文章

Related Posts with Thumbnails