Fix screenshots and continue implementing phantomas v2

This commit is contained in:
Gaël Métais
2020-10-04 02:43:10 +02:00
parent e19a521c4e
commit ac915e8973
8 changed files with 161 additions and 135 deletions
+47 -5
View File
@@ -17,7 +17,7 @@ var PhantomasWrapper = function() {
var deferred = Q.defer();
var task = data.params;
var options = {
/*var options = {
// Cusomizable options
'engine': task.options.phantomasEngine || 'webkit',
@@ -59,6 +59,51 @@ var PhantomasWrapper = function() {
].join(',')
};
*/
var options = {
// Cusomizable options
'timeout': task.options.timeout || 60,
'user-agent': (task.options.device === 'desktop') ? 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) YLT Chrome/85.0.4183.121 Safari/537.36' : null,
'tablet': (task.options.device === 'tablet'),
'phone': (task.options.device === 'phone'),
'screenshot': task.options.screenshot || false,
'viewport': (task.options.device === 'desktop') ? '1280x800x1' : null,
'wait-for-network-idle': true,
//'wait-for-selector': task.options.waitForSelector,
'cookie': task.options.cookie,
'auth-user': task.options.authUser,
'auth-pass': task.options.authPass,
'block-domain': task.options.blockDomain,
'allow-domain': task.options.allowDomain,
'no-externals': task.options.noExternals,
// Mandatory
'analyze-css': true,
'ignore-ssl-errors': true,
/*'skip-modules': [
'ajaxRequests', // overridden
'domHiddenContent', // overridden
'domMutations', // not compatible with webkit
'domQueries', // overridden
'events', // overridden
'filmStrip', // not needed
'har', // not needed for the moment
'javaScriptBottlenecks', // needs to be launched after custom module scopeYLT
'jQuery', // overridden
'jserrors', // overridden
'lazyLoadableImages', //overridden
'pageSource', // not needed
'windowPerformance' // overridden
].join(','),*/
/*'include-dirs': [
path.join(__dirname, 'custom_modules/core'),
path.join(__dirname, 'custom_modules/modules')
].join(',')*/
};
// Proxy option can't be set to null or undefined...
// this is why it's set now and not in the object above
if (task.options.proxy) {
@@ -67,10 +112,7 @@ var PhantomasWrapper = function() {
// It's time to launch the test!!!
const promise = phantomas(task.url, {
'analyze-css': true,
'screenshot': true
});
const promise = phantomas(task.url, options);
// handle the promise
promise.