Skip to content

Instantly share code, notes, and snippets.

@antonioortegajr
Created August 8, 2018 21:39
Show Gist options
  • Save antonioortegajr/f3483939bdb201ecb35be4c7d6a7dc31 to your computer and use it in GitHub Desktop.
Save antonioortegajr/f3483939bdb201ecb35be4c7d6a7dc31 to your computer and use it in GitHub Desktop.
'use strict';
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const setup = require('./starter-kit/setup');
exports.handler = (() => {
var _ref = _asyncToGenerator(function* (event, context, callback) {
// For keeping the browser launch
context.callbackWaitsForEmptyEventLoop = false;
const browser = yield setup.getBrowser();
exports.run(browser).then(function (result) {
return callback(null, result);
}).catch(function (err) {
return callback(err);
});
});
return function (_x, _x2, _x3) {
return _ref.apply(this, arguments);
};
})();
exports.run = (() => {
var _ref2 = _asyncToGenerator(function * (browser) {
// implement here
// this is sample
const page = yield browser.newPage();
yield page.goto('http://antonioortegajr.com', { waitUntil: ['domcontentloaded', 'networkidle0'] });
console.log(yield page.title());
yield page.close();
return 'done';
});
return function (_x4) {
return _ref2.apply(this, arguments);
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment