Skip to content

Instantly share code, notes, and snippets.

View EeroHeroHeino's full-sized avatar

EeroHeroHeino

View GitHub Profile
var express = require('express')
, cors = require('cors')
, app = express();
var fs = require('fs');
app.use(cors());
app.post('/post', function(req, res, next){
var body = [];
req.on('data', function(chunk) {
// send GLOBALS.saveData to external server
$.ajax({
url: "https://example.com:8000/post",
error: function(x, err){
callback("Save timed out with "+err);
},
success: function(){
callback(true);
},
type: "POST",
function randomDate(start, end) {
return new Date(start.getTime() + Math.random() * (end.getTime() - start.getTime()));
}
// getting a random date picked between 1/1/2012 and today
var date = randomDate(new Date(2012, 0, 1), new Date());
// assign the date in format MM/DD/YYYY to a GLOBALS variable "date" for later use
GLOBALS.date = (date.getMonth() + 1)+'/'+date.getDate()+'/'+date.getFullYear();
callback(true);
//separate username part from email address and set it up as a variable "randomEmail" for later use
GLOBALS.randomEmail = GLOBALS['random.myuniquestring@mail.usetrace.com']
callback(true);
// Clicking link with the text "Click link"
var links = [].filter.call(document.querySelectorAll("a"), el => el.textContent.indexOf("Click Link") === 0);
if (links.length == 0) {
return callback(new Error("No link found"));
}
links[0].click()
callback(true);
if (!GLOBALS.poll_time) {
var poll_timeout_seconds = 3;
} else {
var poll_timeout_seconds = GLOBALS.poll_time;
}
var element = "iframe.iframe-book";
var element_text = "Text on the page we want to find";
var poll_frequency_ms = 500;
// Load jquery into jQuery-variable.
// You need to load this in the js step you want to use it.
(function(jqueryUrl, callback) {
if (typeof jqueryUrl != 'string') {
jqueryUrl = 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js';
}
if (typeof jQuery == 'undefined') {
var script = document.createElement('script');
var head = document.getElementsByTagName('head')[0];
// Add js step before this step which defines
// - GLOBALS.download_file_link CSS locator to an element with src for the file
// - GLOBALS.expected_download_status optionally expected some other response status than 200
if (!GLOBALS.download_file_link) {
callback("JS-step GLOBALS.download_file_link not set");
}
if (!GLOBALS.expected_download_status) {
var expected_status = 200;
} else {
// Add js step before this step which defines
// - GLOBALS.not_showing CSS locator
// - GLOBALS.poll_time to optionally wait a different time than 3 seconds
if (!GLOBALS.not_showing) {
callback("JS-step GLOBALS.not_showing not set");
}
var locator = GLOBALS.not_showing;
if (!GLOBALS.poll_time) {
var poll_timeout_seconds = 3;