This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"faceId": "2f3e1309-6e6f-4c2c-92a0-c68d898ba571", | |
"faceRectangle": { // Tọa độ khuôn mặt | |
"top": 109, | |
"left": 209, | |
"width": 109, | |
"height": 109 | |
}, | |
"faceLandmarks": { // Đặc điểm nhận dạng |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const rp = require('request-promise'); | |
async function detectImage(source) { | |
const subscriptionKey = "[thay bằng key của bạn]"; | |
const uri = "https://westcentralus.api.cognitive.microsoft.com/face/v1.0/detect"; | |
const options = { | |
uri, | |
qs: { | |
returnFaceId: true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm init | |
npm install --save-dev request request-promise jimp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test('Install app', async() => { | |
expect.assertions(1); | |
// Tìm và click vào link | |
const appDownloadLink = await page.$x('//*[@id="topActionDownload"]'); | |
await appDownloadLink[0].click(); | |
await page.waitForNavigation(); | |
// Tìm element trên menu, lấy innerText của element đó | |
const breadCrumbHandle = await page.$x('/html/body/header/footer/div[2]/div[1]/ul/li[2]/span'); | |
const text = await page.evaluate(element => element.innerText, breadCrumbHandle[0]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test('Search sexy underwear', async() => { | |
expect.assertions(1); | |
// Tìm khung search, gõ sexy underwear và bấm enter | |
const searchBox = await page.$('#q'); | |
await searchBox.type('sexy underwear'); | |
await searchBox.press('Enter'); | |
// Chờ trang load xong, tìm các phần tử item và đếm nếu đủ 40 | |
await page.waitForNavigation(); | |
const products = await page.$$('div[data-qa-locator=product-item]'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let puppeteer = require('puppeteer'); | |
let browser = null; | |
let page = null; | |
describe('Lazada test', () => { | |
// Code này được chạy khi bắt đầu chạy unit test | |
beforeAll(async() => { | |
browser = await puppeteer.launch(); | |
page = await browser.newPage(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test('One plus one equal 2', async() => { | |
expect(1 + 1).toBe(2); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "puppet-test", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "jest --verbose true" | |
}, | |
"author": "", | |
"license": "ISC", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm init | |
npm install --save jest | |
npm install --save puppeteer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const puppeteer = require('puppeteer'); | |
const download = require('image-downloader'); | |
(async() => { | |
const browser = await puppeteer.launch(); | |
console.log('Browser openned'); | |
const page = await browser.newPage(); | |
const url = 'http://kenh14.vn/ai-roi-cung-khac-cac-hot-girl-nay-cung-khong-ngoai-le-khi-vong-1-cu-ngay-cang-phong-phao-20171207193958533.chn'; | |
await page.goto(url); | |
console.log('Page loaded'); |