From bb2f0e6c55f80e638f26f36ba7fb0418597ca987 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Mon, 4 May 2015 15:24:00 +0200 Subject: [PATCH] Add a cookie advanced option on the front page --- bin/cli.js | 14 ++++++++++++++ front/src/js/services/apiService.js | 6 +++++- front/src/views/index.html | 8 ++++---- lib/server/controllers/apiController.js | 12 ++++++++++-- lib/tools/phantomas/phantomasWrapper.js | 5 ++++- test/api/apiTest.js | 12 ++++++++++-- 6 files changed, 47 insertions(+), 10 deletions(-) diff --git a/bin/cli.js b/bin/cli.js index b22da78..7d4d4a0 100644 --- a/bin/cli.js +++ b/bin/cli.js @@ -15,6 +15,10 @@ var cli = meow({ ' --device Use "phone" or "tablet" to simulate a mobile device (by user-agent and viewport size).', ' --screenshot Will take a screenshot and use this value as the output path. It needs to end with ".png".', ' --js-deep-analysis When activated, the javascriptExecutionTree will contain sub-requests.', + ' --wait-for-selector Once the page is loaded, Phantomas will wait until the given CSS selector matches some elements.', + ' --cookie Adds a cookie on the main domain.', + ' --auth-user Basic HTTP authentication username.', + ' --auth-pass Basic HTTP authentication password.', '' ].join('\n'), pkg: '../package.json' @@ -54,6 +58,16 @@ if (cli.flags.jsDeepAnalysis === true || cli.flags.jsDeepAnalysis === 'true') { // Device simulation options.device = cli.flags.device || 'desktop'; +// Wait for CSS selector +options.waitForSelector = cli.flags.waitForSelector || null; + +// Cookie +options.cookie = cli.flags.cookie || null; + +// HTTP basic auth +options.authUser = cli.flags.authUser || null; +options.authPass = cli.flags.authPass || null; + (function execute(url, options) { 'use strict'; diff --git a/front/src/js/services/apiService.js b/front/src/js/services/apiService.js index ed5dc9d..c0234bc 100644 --- a/front/src/js/services/apiService.js +++ b/front/src/js/services/apiService.js @@ -10,7 +10,11 @@ apiService.factory('API', ['$location', 'Runs', 'Results', function($location, R waitForResponse: false, screenshot: true, jsTimeline: true, - device: settings.device + device: settings.device, + waitForSelector: settings.waitForSelector, + cookie: settings.cookie, + authUser: settings.authUser, + authPass: settings.authPass, }; if (settings.waitForSelector && settings.waitForSelector !== '') { diff --git a/front/src/views/index.html b/front/src/views/index.html index fbea1b2..aff58e1 100644 --- a/front/src/views/index.html +++ b/front/src/views/index.html @@ -22,7 +22,7 @@ authentication
-
+
Cookie @@ -42,7 +42,7 @@
-
+