Sitespeed.io: Unable to use 4.0 new parameter --browsertime.preTask

Created on 27 May 2016  ·  55Comments  ·  Source: sitespeedio/sitespeed.io

Hi Peter,

Thanks for your example.:
https://github.com/tobli/browsertime/blob/1.0/test/preposttasks/preLoginEx
ample.js
I copied the example file as
“/Users/lguo/git/sitespeed.io/test/helpers/login.js”, and modified my
package.json to include "selenium-webdriver”, and did npm install.

However, I am still unable to use it. I added some logs to engine.js, but
still cannot figure out why. Could you help me?

➜ sitespeed.io git:(master) ✗ bin/sitespeed.js
--browsertime.preTask=/Users/lguo/git/sitespeed.io/test/helpers/login.js
https://wikipedia.org
[2016-05-24 18:47:38] Versions OS: darwin 14.5.0 sitespeed.io:
4.0.0-alpha.1 browsertime: 1.0.0-alpha.18 coach: 0.22.3
======== temp log ======= options:
{"statistics":true,"preTask":"/Users/lguo/git/sitespeed.io/test/helpers/log
in.js","browser":"firefox","iterations":3,"viewPort":"1366x708","coach":tru
e,"resultBaseDir":"/Users/lguo/git/sitespeed.io/sitespeed-result/wikipedia.
org/2016-05-24-18-47-38"}
======== temp log ======= this.options:
{"scripts":[],"iterations":3,"delay":0,"experimental":{},"statistics":true,
"preTask":"/Users/lguo/git/sitespeed.io/test/helpers/login.js","browser":"f
irefox","viewPort":"1366x708","coach":true,"resultBaseDir":"/Users/lguo/git
/sitespeed.io/sitespeed-result/wikipedia.org/2016-05-24-18-47-38"}
[2016-05-24 18:47:38] Starting firefox for analysing https://wikipedia.org
3 time(s)
======== temp log ======= options.preTask:
/Users/lguo/git/sitespeed.io/test/helpers/login.js
======== temp log ======= runIteration: 0
[2016-05-24 18:47:41] TypeError: preTask.run is not a function
at
/Users/lguo/git/sitespeed.io/node_modules/browsertime/lib/core/engine.js:13
0:63
From previous event:
at
/Users/lguo/git/sitespeed.io/node_modules/browsertime/lib/core/engine.js:13
0:28
From previous event:
at runIteration
(/Users/lguo/git/sitespeed.io/node_modules/browsertime/lib/core/engine.js:1
30:10)
at
/Users/lguo/git/sitespeed.io/node_modules/browsertime/lib/core/engine.js:20
2:25
From previous event:
at
/Users/lguo/git/sitespeed.io/node_modules/browsertime/lib/core/engine.js:20
1:17
From previous event:
at Engine.run
(/Users/lguo/git/sitespeed.io/node_modules/browsertime/lib/core/engine.js:2
00:8)
at
/Users/lguo/git/sitespeed.io/lib/plugins/browsertime/analyzer.js:90:26
From previous event:
at Object.analyzeUrl
(/Users/lguo/git/sitespeed.io/lib/plugins/browsertime/analyzer.js:90:8)
at Object.processMessage
(/Users/lguo/git/sitespeed.io/lib/plugins/browsertime/index.js:136:27)
at /Users/lguo/git/sitespeed.io/lib/support/queueHandler.js:157:57
at drainItem
(/Users/lguo/git/sitespeed.io/node_modules/concurrent-queue/index.js:92:21)
at Immediate.drain as _onImmediate
at processImmediate as _immediateCallback
[2016-05-24 18:47:41] Render HTML for 1 page(s)
[2016-05-24 18:47:41] Failing:
/Users/lguo/git/sitespeed.io/lib/plugins/html/templates/index.jade:48
46| .row
47| .one-third.column

48| +boxInfo('200 responses',
pagexray.summary.responseCodes['200'])
49| .one-third.column
50| +boxInfo('301 responses',
pagexray.summary.responseCodes['301'])
51| .one-third.column

Cannot read property 'summary' of undefined

Thanks,
Liya

bug

Most helpful comment

@rschoessler @soulgalore Thanks a lot to both of you. I removed the repository and reinstall it. Now, it looks good!
➜ sitespeed.io git:(master) ✗ bin/sitespeed.js --browsertime.preScript=//Users/lguo/git/sitespeed.io/test/helpers/preSample.js https://www.sitespeed.io
[2016-06-08 12:49:16] Versions OS: darwin 14.5.0 sitespeed.io: 4.0.0-alpha.2 browsertime: 1.0.0-alpha.20 coach: 0.23.0
[2016-06-08 12:49:16] Starting firefox for analysing https://www.sitespeed.io 3 time(s)
[2016-06-08 12:49:16] Testing url https://www.sitespeed.io run 1
[2016-06-08 12:49:19] In pretask!!!
[2016-06-08 12:49:20] Loaded page with title: Sitespeed.io - Analyze your website speed and performance
[2016-06-08 12:49:22] Testing url https://www.sitespeed.io run 2
[2016-06-08 12:49:25] In pretask!!!
[2016-06-08 12:49:28] Testing url https://www.sitespeed.io run 3
[2016-06-08 12:49:30] In pretask!!!
[2016-06-08 12:49:33] Render HTML for 1 page(s)
[2016-06-08 12:49:34] HTML stored in /Users/lguo/git/sitespeed.io/sitespeed-result/www.sitespeed.io/2016-06-08-12-49-16
[2016-06-08 12:49:34] Finished analysing https://www.sitespeed.io

All 55 comments

It's a miscommunication of how sitespeed & browsertime talk to each other. Lets implement it the same way as Browsertime CLI does it.

I've fixed this in https://github.com/tobli/browsertime/pull/145, lets make sure it gets in alpha-2

Thanks you so much, Peter! I am really looking forward to the coming alpha-2 version release

When do you anticipate alpha 2? I am very interested in this as well.

Hey @rschoessler here's the schedule: https://github.com/sitespeedio/sitespeed.io/milestones
We are a little behind and will probably need to move alpha3/beta1, but alpha2 will come next week.

this is fixed now, will come in alpha.2

hey @LiyaGuo I just released alpha.2 do you have time to test it? If it works for you, it would be super if you could do a small write-up how make it work, so we can share it with other users (I haven't had time to add more docs yet).

Best
Peter

Hi Peter,
Thanks for your notice and fast response. But I tested it, the log still shows preTask.run is not a function. Is this conmmand correct?

➜ sitespeed.io git:(master) ✗ bin/sitespeed.js --browsertime.preTask=/Users/lguo/git/sitespeed.io/test/helpers/login.js https://wikipedia.org
[2016-06-07 12:26:09] Versions OS: darwin 14.5.0 sitespeed.io: 4.0.0-alpha.2 browsertime: 1.0.0-alpha.20 coach: 0.23.0
======== temp log ======= options: {"statistics":true,"preTask":"/Users/lguo/git/sitespeed.io/test/helpers/login.js","browser":"firefox","iterations":3,"connection":"native","viewPort":"1366x708","resultDir":"/Users/lguo/git/sitespeed.io/sitespeed-result/wikipedia.org/2016-06-07-12-26-09"}
======== temp log ======= this.options: {"scripts":[],"iterations":3,"delay":0,"experimental":{},"statistics":true,"preTask":"/Users/lguo/git/sitespeed.io/test/helpers/login.js","browser":"firefox","connection":"native","viewPort":"1366x708","resultDir":"/Users/lguo/git/sitespeed.io/sitespeed-result/wikipedia.org/2016-06-07-12-26-09"}
[2016-06-07 12:26:09] Starting firefox for analysing https://wikipedia.org 3 time(s)
======== temp log ======= options.preTask: /Users/lguo/git/sitespeed.io/test/helpers/login.js
======== temp log ======= runIteration: 0
[2016-06-07 12:26:12] TypeError: preTask.run is not a function
at /Users/lguo/git/sitespeed.io/node_modules/browsertime/lib/core/engine.js:130:63
From previous event:
at /Users/lguo/git/sitespeed.io/node_modules/browsertime/lib/core/engine.js:130:28
From previous event:
at runIteration (/Users/lguo/git/sitespeed.io/node_modules/browsertime/lib/core/engine.js:130:10)
at /Users/lguo/git/sitespeed.io/node_modules/browsertime/lib/core/engine.js:202:25
From previous event:
at /Users/lguo/git/sitespeed.io/node_modules/browsertime/lib/core/engine.js:201:17
From previous event:
at Engine.run (/Users/lguo/git/sitespeed.io/node_modules/browsertime/lib/core/engine.js:200:8)
at /Users/lguo/git/sitespeed.io/lib/plugins/browsertime/analyzer.js:90:26
From previous event:
at Object.analyzeUrl (/Users/lguo/git/sitespeed.io/lib/plugins/browsertime/analyzer.js:90:8)
at Object.processMessage (/Users/lguo/git/sitespeed.io/lib/plugins/browsertime/index.js:136:27)
at /Users/lguo/git/sitespeed.io/lib/support/queueHandler.js:157:57
at drainItem (/Users/lguo/git/sitespeed.io/node_modules/concurrent-queue/index.js:92:21)
at Immediate.drain as _onImmediate
at processImmediate as _immediateCallback
[2016-06-07 12:26:12] Render HTML for 1 page(s)

we renamed it to preScript, check help or README.md, I've missed to mention it in this issue, sorry! :)

Greetings...i was able to get this to work using the new code and preScript. Much thanks.

Thanks for the update. The program now accepts the preScript parameter. However it is not running the JS file I provided.

This is my login.js:

'use strict';
let webdriver = require('selenium-webdriver');
module.exports = {
  run(context) {
    console.log("===============run ");
    console.log("Context:" + JSON.stringify(context));
    return context.runWithDriver((driver) => {
      return driver.get('https://en.wikipedia.org/w/index.php?title=Special:UserLogin&returnto=Main+Page')
        .then(() => {
          var userName = '****************';
          var password = '**************';
          var loginForm = driver.findElement(webdriver.By.tagName('form'));
          console.log("===============loginForm ");
          console.log("Context:" + JSON.stringify(loginForm));
          var loginInput = driver.findElement(webdriver.By.id('wpName1'));
          console.log("===============loginInput ");
          console.log("Context:" + JSON.stringify(loginInput));
          loginInput.sendKeys(userName);
          var passwordInput = driver.findElement(webdriver.By.id('wpPassword1'));
          console.log("===============passwordInput ");
          console.log("Context:" + JSON.stringify(passwordInput));
          passwordInput.sendKeys(password);
          loginForm.submit();
        });
    })
  }
};

Here is the log I got:

➜  sitespeed.io git:(master) ✗ bin/sitespeed.js --preScript=/Users/lguo/git/sitespeed.io/test/helpers/login.js https://en.wikipedia.org/
[2016-06-07 17:15:00] Versions OS: darwin 14.5.0 sitespeed.io: 4.0.0-alpha.2 browsertime: 1.0.0-alpha.20 coach: 0.23.0
======== temp log ======= options: {"statistics":true,"preScript":"/Users/lguo/git/sitespeed.io/test/helpers/login.js","browser":"firefox","iterations":3,"connection":"native","viewPort":"1366x708","resultDir":"/Users/lguo/git/sitespeed.io/sitespeed-result/en.wikipedia.org/2016-06-07-17-15-00"}
======== temp log ======= this.options: {"scripts":[],"iterations":3,"delay":0,"experimental":{},"statistics":true,"preScript":"/Users/lguo/git/sitespeed.io/test/helpers/login.js","browser":"firefox","connection":"native","viewPort":"1366x708","resultDir":"/Users/lguo/git/sitespeed.io/sitespeed-result/en.wikipedia.org/2016-06-07-17-15-00"}
[2016-06-07 17:15:00] Starting firefox for analysing https://en.wikipedia.org/ 3 time(s)
======== temp log ======= runIteration: 0
======== temp log ======= runIteration: 1
======== temp log ======= runIteration: 2
[2016-06-07 17:15:18] Render HTML for 1 page(s) 
[2016-06-07 17:15:20] HTML stored in /Users/lguo/git/sitespeed.io/sitespeed-result/en.wikipedia.org/2016-06-07-17-15-00
[2016-06-07 17:15:20] Finished analysing https://en.wikipedia.org/

@rschoessler Hi, could you please share your preScript test with me? Thanks you so much.
Best regards,
Liya

@LiyaGuo sure no problem.

'use strict';
let webdriver = require('selenium-webdriver');
module.exports = {
  run(context) {
    return context.runWithDriver((driver) => {
      return driver.get('https://en.wikipedia.org/w/index.php?title=Special:UserLogin&returnto=Main+Page')
        .then(() => {
          var userName = 'username';
          var password = 'password';
          var loginForm = driver.findElement(webdriver.By.tagName('form'));
          var loginInput = driver.findElement(webdriver.By.id('wpName1'));
          loginInput.sendKeys(userName);
          var passwordInput = driver.findElement(webdriver.By.id('wpPassword1'));
          passwordInput.sendKeys(password);
          loginForm.submit();
        });
    })
  }
};

Once you have this (looks like you already do), use the following command to run it (or something similar depending on the path to your .js file):

c:\sitespeed\sitespeed.io>node bin\sitespeed.js --browsertime.preScript=c:\sitespeed\sitespeed.io\test\helpers\preLoginExample.js https://en.wikipedia.org/wiki/Wikipedia

...or...

c:\sitespeed\sitespeed.io>node bin\sitespeed.js --preScript c:\sitespeed\sitespeed.io\test\helpers\preLoginExample.js https://en.wikipedia.org/wiki/Wikipedia

The main Wikipedia login page does appear to use Captcha to force you to type in a string at times before it allows you to log in. That did cause my script to fail until I got past that manually.

Best of luck!

Hey @LiyaGuo sorry for not getting back. I tried this morning but couldn't reproduce, hoped that someone would see what's wrong.

Simplest test I'm using is https://github.com/tobli/browsertime/blob/1.0/test/prepostscripts/preSample.js

If you get the log In pretask!!!' that task runs.

Best
Peter

@rschoessler @soulgalore Thanks a lot to both of you. I removed the repository and reinstall it. Now, it looks good!
➜ sitespeed.io git:(master) ✗ bin/sitespeed.js --browsertime.preScript=//Users/lguo/git/sitespeed.io/test/helpers/preSample.js https://www.sitespeed.io
[2016-06-08 12:49:16] Versions OS: darwin 14.5.0 sitespeed.io: 4.0.0-alpha.2 browsertime: 1.0.0-alpha.20 coach: 0.23.0
[2016-06-08 12:49:16] Starting firefox for analysing https://www.sitespeed.io 3 time(s)
[2016-06-08 12:49:16] Testing url https://www.sitespeed.io run 1
[2016-06-08 12:49:19] In pretask!!!
[2016-06-08 12:49:20] Loaded page with title: Sitespeed.io - Analyze your website speed and performance
[2016-06-08 12:49:22] Testing url https://www.sitespeed.io run 2
[2016-06-08 12:49:25] In pretask!!!
[2016-06-08 12:49:28] Testing url https://www.sitespeed.io run 3
[2016-06-08 12:49:30] In pretask!!!
[2016-06-08 12:49:33] Render HTML for 1 page(s)
[2016-06-08 12:49:34] HTML stored in /Users/lguo/git/sitespeed.io/sitespeed-result/www.sitespeed.io/2016-06-08-12-49-16
[2016-06-08 12:49:34] Finished analysing https://www.sitespeed.io

Hi @soulgalore, may I ask one more question? Why the crawler won't crawl the child pages anymore if i use the preScript option? It only gives the report of the url in the command.

Hey @LiyaGuo , it was a bug in alpha.2 the same as #986. I've fixed it now with alpha.3. Feel free to create a new issue when you find something new :)

Best
Peter

@LiyaGuo @soulgalore is this working for you on Mac with version 4.0.0-alpha.3? I am getting an error:

xxxxxxx$ bin/sitespeed.js --browsertime.preScript=//Users/xxxxxxx/sitespeed.io/test/helpers/wikipedia.js https://en.wikipedia.org/wiki/Wikipedia
[2016-06-16 12:45:55] Versions OS: darwin 15.4.0 sitespeed.io: 4.0.0-alpha.3 browsertime: 1.0.0-alpha.20 coach: 0.23.0
[2016-06-16 12:45:56] Couldn't load task file: //Users/xxxxxxx/sitespeed.io/test/helpers/wikipedia.js
[2016-06-16 12:45:56] Error: Couldn't load task file: //Users/xxxxxxx/sitespeed.io/test/helpers/wikipedia.js
at /Users/xxxxxxx/sitespeed.io/node_modules/browsertime/lib/core/engine.js:31:13
at Array.map (native)
at loadPrePostScripts (/Users/xxxxxxx/sitespeed.io/node_modules/browsertime/lib/core/engine.js:27:32)
at new Engine (/Users/xxxxxxx/sitespeed.io/node_modules/browsertime/lib/core/engine.js:40:29)
at Object.analyzeUrl (/Users/xxxxxxx/sitespeed.io/lib/plugins/browsertime/analyzer.js:87:18)
at Object.processMessage (/Users/xxxxxxx/sitespeed.io/lib/plugins/browsertime/index.js:136:27)
at /Users/xxxxxxx/sitespeed.io/lib/support/queueHandler.js:157:57
at drainItem (/Users/xxxxxxx/sitespeed.io/node_modules/concurrent-queue/index.js:92:21)
at Immediate.drain as _onImmediate
at processImmediate as _immediateCallback

I don't know if this worked before because I didn't try it on Mac. This works fine on Windows for me now with same versions.

Hmm, is that really a valid path? UNIX/Mac absolute paths starts with a single slash, not two as on Windows.

@tobli single slash reveals same result. Here's my path:

helpers rschoessler$ pwd
/Users/rschoessler/sitespeed.io/test/helpers
helpers rschoessler$ ls -la | grep wiki
-rw-r--r--@ 1 rschoessler staff 735 Jun 16 12:43 wikipedia.js
.....
Couldn't load task file: /Users/rschoessler/sitespeed.io/test/helpers/wikipedia.js

yep @rschoessler you are right, absolute paths don't work, relative do.

hmm, wait that was wrong, I can use an absolute path, I put in the wrong path when I tried last time (checked the history) :blush:

I cannot reproduce, I wonder what it is.

So I downloaded to a new directory on Windows, went through the same set up (or so I thought) and I am now getting the same problem on Windows. Argh. When running through the first directory, that's not working either now.

@soulgalore @tobli whenever I try to do a fresh git clone, npm install, I am unable to get the preScript to work on either OS. The only thing that I noticed on my two windows implementations was that the first (working) clone has a folder for Jade in the node-modules dir and all new ones do not. Any help would be appreciated. I don't do a lot with node so maybe there's something I goofed.

yes thanks, I will try to reproduce tonight/tomorrow, appreciate that you try different things :)

@rschoessler I've added a test in Travis so we automatically run them and test a preScript and a postScript. They work fine, I wonder what it could be? Could you try to update the project (so you get the test scripts) and then run as in Travis:
https://github.com/sitespeedio/sitespeed.io/blob/master/.travis.yml#L31

Well, both of those scripts do work fine it seems. However, I still get the error when trying to run a script that uses selenium-webdriver on new clones. If I do a git clone to a new directory on any machine, I can't seem to get it to work now.

When I git pull from my original windows directory where I started with alpha.1 a few weeks ago, everything seems to work fine including prescripts with selenium. Perhaps I am missing a setup step with new repo's?

Hi @rschoessler!
Unless you're actively doing development it'll be easier to install prereleases via npm, than running from a checked out git workspace. When running from a git workspace you'll need to run npm update after the first pull, and whenever a dependency in package.json changes.

To install via npm you can run:

npm i -g [email protected] <- for a specific pre-release version
npm i -g sitespeed.io@canary <- for the latest pre-release version

Otherwise make sure to run npm update in your git workspace.

I'm having issues with docker container and volume mapping... my script is on the aws instance and the folder is mapped to /sitespeed.io folder inside the container... it is able to read the url list file but not the prescriptlogin.js....

sudo docker run --privileged --rm -v /home/ec2-user/sitespeed.io:/sitespeed.io sitespeedio/sitespeed.io:4.0-alpha sitespeed.io --preScript=preloginscript.js myvzurllist.txt --graphite.host 1.1.1.1 --graphite.namespace xxxxxxx -b firefox -n 1 -v

[2016-07-02 01:19:38] Will analyse 9 URLs from myvzurllist.txt [LOADED THIS FILE]
[2016-07-02 01:19:38] Couldn't load task file: preloginscript.js [DOESNT LOAD THIS FILE]
[2016-07-02 01:19:38] Error: Couldn't load task file: preloginscript.js

As a workaround for now, could you test with an absolute URL, in this case I think it should be /sitespeed.io/preloginscript.js (inside the container)?

tried to use the absolute path as well - still didnt work... i dont know where its looking for the preloginscript.js.. the folder is mapped correctly... using -v... since its finding one file but just not the next one..

Also, i tried on my mac... and on my mac --- it dont run into this issue... on mac... it runs into "invalid locator" issue - this issue i reported on a separate thread.. so not sure whats the deal... why on ec2 amazon linx -- it dosnt find the js file..whereas its running into selenium firefox -- invalid locator issue on mac

hello....i am still not able to get the --preScript to work on either my Mac or Windows. I either get "couldn't load task file" (Mac) or "invalid locator" on Windows. Is anyone able to get this to work? This is definitely a bummer that this isn't working...4.0.0-alpha.5

Hey @rschoessler ,
I've updated the error message but didn't do a release. I've added a test file for Travis, do that work for you? https://github.com/sitespeedio/sitespeed.io/blob/master/test/prepostscripts/preSample.js

See if we can push the beta after the weekend.

Best
Peter

@soulgalore that script works for me. But a previous script that actually was working that used Selenium, did not.

I posted that full script on Jun 8 in this thread. Here's the full error that I get now when running it:

c:\sitespeed\sitespeed.io\bin>node sitespeed.js --browsertime.preScript=c:\sitespeed\sites
peed.io\test\helpers\preLoginExample.js https://en.wikipedia.org/wiki/Wikipedia
[2016-08-10 09:34:30] Versions OS: win32 6.1.7601 nodejs: v4.4.4 sitespeed.io: 4.0.0-alpha
.5 browsertime: 1.0.0-alpha.22 coach: 0.24.2
[2016-08-10 09:34:32] Starting chrome for analysing https://en.wikipedia.org/wiki/Wikipedi
a 3 time(s)
[2016-08-10 09:34:32] Testing url https://en.wikipedia.org/wiki/Wikipedia run 1
[2016-08-10 09:34:36] TypeError: Invalid locator
    at Object.check [as checkedLocator] (c:\sitespeed\sitespeed.io\node_modules\browsertim
e\node_modules\selenium-webdriver\lib\by.js:267:9)
    at Driver.findElement (c:\sitespeed\sitespeed.io\node_modules\browsertime\node_modules
\selenium-webdriver\lib\webdriver.js:857:18)
    at c:\sitespeed\sitespeed.io\test\helpers\preLoginExample.js:10:34
    at ManagedPromise.invokeCallback_ (c:\sitespeed\sitespeed.io\node_modules\browsertime\
node_modules\selenium-webdriver\lib\promise.js:1379:14)
    at TaskQueue.execute_ (c:\sitespeed\sitespeed.io\node_modules\browsertime\node_modules
\selenium-webdriver\lib\promise.js:2913:14)
    at TaskQueue.executeNext_ (c:\sitespeed\sitespeed.io\node_modules\browsertime\node_mod
ules\selenium-webdriver\lib\promise.js:2896:21)
    at c:\sitespeed\sitespeed.io\node_modules\browsertime\node_modules\selenium-webdriver\
lib\promise.js:2775:27
    at c:\sitespeed\sitespeed.io\node_modules\browsertime\node_modules\selenium-webdriver\
lib\promise.js:639:7
    at process._tickCallback (node.js:369:9)
[2016-08-10 09:34:36] Render HTML for 1 page(s)
[2016-08-10 09:34:36] Error TypeError: c:\sitespeed\sitespeed.io\lib\plugins\html\template
s\assets.pug:5
    3|
    4| mixin rows(assets)
  > 5|   each asset in assets
    6|     tr
    7|       td.url.assetsurl(data-title='URL')
    8|         a(href=asset.url)= asset.shortURL

Cannot read property 'length' of undefined
    3|
    4| mixin rows(assets)
  > 5|   each asset in assets
    6|     tr
    7|       td.url.assetsurl(data-title='URL')
    8|         a(href=asset.url)= asset.shortURL

Cannot read property 'length' of undefined
    at Object.pug_mixins.rows.pug_interp [as rows] (eval at wrap (c:\sitespeed\sitespeed.i
o\node_modules\pug\node_modules\pug-runtime\wrap.js:6:10), <anonymous>:90:32)
    at eval (eval at wrap (c:\sitespeed\sitespeed.io\node_modules\pug\node_modules\pug-run
time\wrap.js:6:10), <anonymous>:292:19)
    at template (eval at wrap (c:\sitespeed\sitespeed.io\node_modules\pug\node_modules\pug
-runtime\wrap.js:6:10), <anonymous>:325:184)
    at c:\sitespeed\sitespeed.io\lib\plugins\html\renderer.js:36:27
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)
From previous event:
    at Object.renderTemplate (c:\sitespeed\sitespeed.io\lib\plugins\html\renderer.js:36:8)

    at HTMLBuilder._renderSummaryPage (c:\sitespeed\sitespeed.io\lib\plugins\html\htmlBuil
der.js:164:67)
    at c:\sitespeed\sitespeed.io\lib\plugins\html\htmlBuilder.js:97:27
    at Array.map (native)
    at HTMLBuilder.renderHTML (c:\sitespeed\sitespeed.io\lib\plugins\html\htmlBuilder.js:9
7:8)
    at Object.close (c:\sitespeed\sitespeed.io\lib\plugins\html\index.js:88:29)
    at c:\sitespeed\sitespeed.io\lib\sitespeed.js:35:49
From previous event:
    at runOptionalFunction (c:\sitespeed\sitespeed.io\lib\sitespeed.js:35:6)
    at c:\sitespeed\sitespeed.io\lib\sitespeed.js:95:32
From previous event:
    at c:\sitespeed\sitespeed.io\lib\sitespeed.js:95:16
    at processImmediate [as _immediateCallback] (timers.js:383:17)
From previous event:
    at c:\sitespeed\sitespeed.io\lib\sitespeed.js:82:12
From previous event:
    at Object.run (c:\sitespeed\sitespeed.io\lib\sitespeed.js:79:8)
    at c:\sitespeed\sitespeed.io\bin\sitespeed.js:24:22
From previous event:
    at Object.<anonymous> (c:\sitespeed\sitespeed.io\bin\sitespeed.js:23:4)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:441:10)
    at startup (node.js:139:18)
    at node.js:968:3

Hey @rschoessler did you try to install the selenium-webdriver globally? It seems like people have had similar problems on Windows before: https://github.com/angular/protractor/issues/988

Best
Peter

@rschoessler @soulgalore the instanceOf check is failing on in By.js (https://github.com/SeleniumHQ/selenium/blob/master/javascript/node/selenium-webdriver/lib/by.js#L258) when using the following script:

var wd = require('selenium-webdriver');

module.exports = {
  run(context) {
    return context.runWithDriver((driver) => {
      return driver.get('XXX')
        .then(() => {

          console.log(driver.By);
          console.log(wd.By);

          driver
            .findElement(wd.By.id('UserName'))
            .sendKeys('XXX');

          driver
            .findElement(wd.By.id('Password'))
            .sendKeys('XXX');

          driver
            .findElement(wd.By.id('login'))
            .submit();
        });
      })
    }
  };

By disabling the instanceOf check in By.js and returning the locator being tested, everything flows through just fine and script executes successfully. I'm not quite sure yet what is causing this exactly. I've trying using 2.53.0 and latest selenium-webdriver to no avail.

Testing with node version 6.3.0

@soulgalore have you been able to run a preScript that includes selenium commands such as I have included?
@LiyaGuo does this work for you?

@rschoessler yep, I've run this: https://github.com/sitespeedio/browsertime/blob/1.0/test/prepostscripts/preLoginExample.js

It could be that you need to globally install selenium, I'll test tomorrow when I have more time.

@soulgalore thanks. We have done multiple global installs on three different machines and get the same errors everywhere.

ok, I think the easiest solution is that we push the selenium-webdriver in the context, so in the pre/postsScript, we can get hold of the exact same version that is used in Browsertime, that will make sure there's no problem. I'll fix that asap tomorrow.

I've patiently been reading and following this thread - since I have the exact same issue

fantastic!

thanks for hanging in there @softwareklinic ;-)

I've pushed the change to master, so if you can run it from there you can try out the new way: https://github.com/sitespeedio/browsertime/blob/1.0/test/prepostscripts/preLoginExample.js

Aiming for pushing first beta early next week, if we can fix https://github.com/sitespeedio/browsertime/issues/175 and we can run all the needed tests.

Not sure where this stands, but FYI...I have done a git pull and npm install and I am still getting the error below:

Error: Cannot find module 'selenium-webdriver'

Followed by....

[2016-08-22 14:34:10] Error: Couldn't run pre/post script file: c:\sitespeed\sitespeed.io\ bin\pretask_file.js Error: Cannot find module 'selenium-webdriver' at c:\sitespeed\sitespeed.io\node_modules\browsertime\lib\core\engine.js:33:13 at Array.map (native) at loadPrePostScripts (c:\sitespeed\sitespeed.io\node_modules\browsertime\lib\core\eng ine.js:29:32) at new Engine (c:\sitespeed\sitespeed.io\node_modules\browsertime\lib\core\engine.js:4 2:29) at Object.analyzeUrl (c:\sitespeed\sitespeed.io\lib\plugins\browsertime\analyzer.js:87 :18) at Object.processMessage (c:\sitespeed\sitespeed.io\lib\plugins\browsertime\index.js:1 38:27) at c:\sitespeed\sitespeed.io\lib\support\queueHandler.js:157:57 at drainItem (c:\sitespeed\sitespeed.io\node_modules\concurrent-queue\index.js:92:21) at Immediate.drain [as _onImmediate] (c:\sitespeed\sitespeed.io\node_modules\concurren t-queue\index.js:73:84) at processImmediate [as _immediateCallback] (timers.js:383:17)

@soulgalore if I use the full path to the browsertime node-modules selenium-webdriver in my require, it'll get past that error...

...only to go back to the Invalid Locator error...

Hey @rschoessler did you have time to check out the new example (the branch has been killed when I posted it before)? https://github.com/sitespeedio/browsertime/blob/master/test/prepostscripts/preLoginExample.js

With the change, you can get the same selenium webdriver used by browsertime (without needing to require it).

  // we fetch the selenium webdriver from context
  var webdriver = context.webdriver;

Or do you get the same problem with that?

Best
Peter

Ok, yes I went to that link before and there was no script there. I did not catch about not needing to require selenium-webdriver. My scripts are working now with that change. Thank you!

is this change in master branch?

@softwareklinic yes.

@rschoessler ah finally, good :)

When.can we have docker build?

Sent from my iPhone

On Aug 23, 2016, at 4:50 PM, Peter Hedenskog <[email protected]notifications@github.com> wrote:

@softwareklinichttps://github.com/softwareklinic yes.

@rschoesslerhttps://github.com/rschoessler ah finally, good :)


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com/sitespeedio/sitespeed.io/issues/962#issuecomment-241891332, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AHMCie2qiKyzAS5k5tGAa7ue2ynbTuZHks5qi2sigaJpZM4IoveQ.

I will try out master tonight

From: Shah Keyur [email protected]keyur.shah@one.verizon.com>
Date: Tuesday, August 23, 2016 at 5:01 PM
To: "sitespeedio/sitespeed.io" <[email protected]reply@reply.github.com>
Cc: "sitespeedio/sitespeed.io" [email protected]sitespeed.io@noreply.github.com>, Shah Keyur [email protected]keyur.shah@one.verizon.com>, Mention <[email protected]mention@noreply.github.com>
Subject: Re: [E] Re: [sitespeedio/sitespeed.io] Unable to use 4.0 new parameter --browsertime.preTask (#962)

When.can we have docker build?

Sent from my iPhone

On Aug 23, 2016, at 4:50 PM, Peter Hedenskog <[email protected]notifications@github.com> wrote:

@softwareklinichttps://github.com/softwareklinic yes.

@rschoesslerhttps://github.com/rschoessler ah finally, good :)


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com/sitespeedio/sitespeed.io/issues/962#issuecomment-241891332, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AHMCie2qiKyzAS5k5tGAa7ue2ynbTuZHks5qi2sigaJpZM4IoveQ.

My login page redirects to a landing page (takes a few seconds) and test gets run not on the URL I asked for, but on the post-login page.

I've resolved the issue for now by adding

          driver.wait(webdriver.until.urlMatches(/account/), 3000);

where 'account' is in the url of the landing page, after loginForm.submit() in preLoginExample.js.

Is there a way to guarantee the test runs on the correct URL -- i.e., there is no latent redirect from an earlier action?

This works for us in dashboard.sitespeed.io, please re-open if you still see a problem.

Was this page helpful?
0 / 5 - 0 ratings