Skip to content

Instantly share code, notes, and snippets.

@AleksandraZuchewicz
AleksandraZuchewicz / test.js
Last active February 19, 2019 22:49
Cashback lottery automated testing
Feature('Lottery test');
Scenario('test stickers distribution', async (I) => {
const letters = ["0", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
I.amOnPage("https://www.somecashbacksite.co.uk/search/merchants/?letter=A");
I.wait(180); // Have a time to log in and do Captcha manually
// Infinetely wander through website
while(true) {
// Go through letters
for (let currentLetter = 0; currentLetter < letters.length; currentLetter++) {
@AleksandraZuchewicz
AleksandraZuchewicz / testCase.js
Created February 22, 2019 17:35
Postman script for API testing automation
pm.test("Response time is less than 300ms", function () {
pm.expect(pm.response.responseTime).to.be.below(300);
});
@AleksandraZuchewicz
AleksandraZuchewicz / visionAPI.js
Last active April 5, 2020 16:52
Used in: Testing explicit content of the website with Google Cloud Vision API -SafeSearch Detection
const vision = require("@google-cloud/vision");
const fileName = "./screenshots/google.png";
const client = new vision.ImageAnnotatorClient();
(async function save() {
const [result] = await client.safeSearchDetection(fileName);
const detections = result.safeSearchAnnotation;
console.log(`Adult: ${detections.adult}`);
console.log(`Medical: ${detections.medical}`);
@AleksandraZuchewicz
AleksandraZuchewicz / detectLanguage.js
Last active June 27, 2023 09:00
Basic Google Cloud Translation API - detectLanguage
const translate = new Translate();
const text = ["这是一个非常好的API", "to jest bardzo dobre API"];
async function detectLanguage() {
let [detections] = await translate.detect(text);
detections = Array.isArray(detections) ? detections : [detections];
console.log("Detections:");
detections.forEach((detection) => {
console.log(detection);
@AleksandraZuchewicz
AleksandraZuchewicz / listLanguages.js
Last active May 11, 2020 15:02
Basic Google Cloud Translation API - List Languages
async function listLanguages() {
const [languages] = await translate.getLanguages();
console.log("Languages:");
languages.forEach((language) => console.log(language));
}
listLanguages();
@AleksandraZuchewicz
AleksandraZuchewicz / translate.js
Last active May 11, 2020 15:01
Basic Google Cloud Translation API - translate
const text = [
"这是一个非常好的API",
"to jest bardzo dobre API",
"это очень хороший API",
];
const target = "en";
async function translateText() {
let [translations] = await translate.translate(text, target);
translations = Array.isArray(translations) ? translations : [translations];