sitespeedio / sitespeed.io

sitespeed.io is an open-source tool for comprehensive web performance analysis, enabling you to test, monitor, and optimize your website’s speed using real browsers in various environments.
https://www.sitespeed.io/
MIT License
4.74k stars 601 forks source link

About Click By XPath for the same URL is failing with this error #2921

Closed softwareklinic closed 4 years ago

softwareklinic commented 4 years ago

No company specific data here so I can share the script

I'm trying below script and running into an issue the last step is not getting recorded

module.exports = async function(context, commands) { // Navigate to a URL, but do not measure the URL

try {
    // start measuring the metrics for home page
    await commands.measure.start('homepage');
    await commands.js.run('document.body.innerHTML = ""; document.body.style.backgroundColor = "white";');
    await commands.navigate('https://www.verizonwireless.com');
    await commands.measure.stop('homepage');

    // start measuing the metrics for SMartphones
    //await commands.measure.start('Smartphones');
    //await commands.js.run('document.body.innerHTML = ""; document.body.style.backgroundColor = "white";');
    await commands.measure.start('https://www.verizonwireless.com/smartphones/','Smartphones');
    //await commands.measure.stop('Smartphones');

    // start measuing the metrics for PDP
    //await commands.measure.start('PDP');
    //await commands.js.run('document.body.innerHTML = ""; document.body.style.backgroundColor = "white";');
    await commands.measure.start('https://www.verizonwireless.com/smartphones/apple-iphone-11-pro-max/','PDP');
    //await commands.measure.stop('PDP');

    // start measuring after clicking  on addtocart
    await commands.measure.start('AddtoCart');
    // Click addto cart button
    // await commands.js.run('document.body.innerHTML = ""; document.body.style.backgroundColor = "white";');
    await commands.click.byXpath('//*[@id="ATC-Btn"]');
    await commands.measure.stop('AddtoCart');

    // Stop and collect the metrics
    return;

} catch (e) { // We try/catch so we will catch if the the input fields can't be found // The error is automatically logged in Browsertime an rethrown here // We could have an alternative flow ... // else we can just let it cascade since it catched later on and reported in // the HTML throw e; } };

ERROR

docker container run --privileged --rm -v /apps/opt/application/sitespeed/sitespeed.io:/sitespeed.io sitespeedio/sitespeed.io --shm-size=1g --axe.enable -n 1 NSE-Prod.js --multi --outputFolder sitespeed-result/NSE-Prod/$(date +\%Y-\%m-\%d-\%H-\%M-\%S) --filmstrip.showAll Google Chrome 79.0.3945.79 Mozilla Firefox 71.0 [2020-03-14 13:57:10] INFO: Versions OS: linux 3.10.0-1062.12.1.el7.x86_64 nodejs: v12.13.0 sitespeed.io: 11.9.3 browsertime: 7.8.3 coach: 4.3.0 [2020-03-14 13:57:10] INFO: Axe plugin activated [2020-03-14 13:57:10] INFO: Running tests using Chrome - 1 iteration(s) [2020-03-14 13:57:11] INFO: Start to measure homepage [2020-03-14 13:57:12] INFO: Navigating to url https://www.verizonwireless.com iteration 1 [2020-03-14 13:57:27] INFO: Testing url https://www.verizonwireless.com/smartphones/ iteration 1 [2020-03-14 13:57:55] INFO: Testing url https://www.verizonwireless.com/smartphones/apple-iphone-11-pro-max/ iteration 1 [2020-03-14 14:00:05] INFO: Start to measure AddtoCart [2020-03-14 14:00:07] INFO: https://www.verizonwireless.com/smartphones/apple-iphone-11-pro-max/ has been tested before within the same run, it will get an extra query parameter named browsertime_run. Make sure to use alias to keep track of the URLs

**NOTE: I'm not calling the last URL 2 times -- just calling the Click by XPath not sure why sitespeed is complaining about "has been tested before within the same run"

AND then below VIDEO recording error**

[2020-03-14 14:00:38] ERROR: The video recording start is zero, either no orange is there in the video or VisualMetrics failed: {"visualMetrics":{"SpeedIndex":300,"FirstVisualChange":34,"LastVisualChange":300,"ContentfulSpeedIndex":34,"videoRecordingStart":0,"PerceptualSpeedIndex":299,"VisualProgress":"0=0%, 34=0%, 300=100%","VisualReadiness":266,"VisualComplete85":300,"VisualComplete95":300,"VisualComplete99":300}} [2020-03-14 14:00:39] ERROR: Could not add meta data to the HAR, miss page 3 [2020-03-14 14:00:39] INFO: https://www.verizonwireless.com/ 117 requests, backEndTime: 151ms, firstPaint: 550ms, firstVisualChange: 600ms, DOMContentLoaded: 650ms, Load: 3.08s, speedIndex: 3414, visualComplete85: 3.67s, lastVisualChange: 8.27s, rumSpeedIndex: 550 [2020-03-14 14:00:39] INFO: https://www.verizonwireless.com/smartphones/ 81 requests, backEndTime: 257ms, firstPaint: 3.94s, firstVisualChange: 4.10s, DOMContentLoaded: 3.67s, Load: 6.90s, speedIndex: 4250, visualComplete85: 4.10s, lastVisualChange: 10.63s, rumSpeedIndex: 4494 [2020-03-14 14:00:39] INFO: https://www.verizonwireless.com/smartphones/apple-iphone-11-pro-max/ 82 requests, backEndTime: 211ms, firstPaint: 1.84s, firstVisualChange: 300ms, DOMContentLoaded: 1.62s, Load: 4.77s, speedIndex: 300, visualComplete85: 300ms, lastVisualChange: 300ms, rumSpeedIndex: 2439 [2020-03-14 14:00:39] INFO: https://www.verizonwireless.com/smartphones/apple-iphone-11-pro-max/?browsertime_run=2 backEndTime: 211ms, firstPaint: 1.84s, firstVisualChange: 34ms, DOMContentLoaded: 1.62s, Load: 4.77s, speedIndex: 300, visualComplete85: 300ms, lastVisualChange: 300ms, rumSpeedIndex: 1906 [2020-03-14 14:00:39] ERROR: Could not find the right index 3 for har for url https://www.verizonwireless.com/smartphones/apple-iphone-11-pro-max/?browsertime_run=2 [2020-03-14 14:00:39] ERROR: Error: PageIndex out of range at module.exports.pickAPage (/usr/src/app/node_modules/webcoach/lib/har/harCutter.js:18:11) at Object.pickAPage (/usr/src/app/node_modules/webcoach/lib/index.js:130:12) at Object.processMessage (/usr/src/app/lib/plugins/browsertime/index.js:229:29) [2020-03-14 14:00:42] INFO: HTML stored in /sitespeed.io/sitespeed-result/NSE-Prod/2020-03-14-09-57-08

soulgalore commented 4 years ago

Hi @softwareklinic thanks for sharing I will try tonight and see what I can find out.

softwareklinic commented 4 years ago

I took another PASS below is the code change

module.exports = async function(context, commands) { // Navigate to a URL, but do not measure the URL

try {
    // start measuring the metrics for home page
    await commands.measure.start('https://www.verizonwireless.com','homepage');

    // start measuring the metrics for SMartphones
    await commands.measure.start('https://www.verizonwireless.com/smartphones/','Smartphones');

    // start measuring the metrics for PDP
    await commands.measure.start('https://www.verizonwireless.com/smartphones/apple-iphone-11-pro-max/','PDP');

    // start measuring after clicking  on addtocart
    await commands.measure.start('add2cart');
    await commands.click.byXpath('//*[@id="ATC-Btn"]');
    await commands.measure.stop();

    // Stop and collect the metrics
    return;

} catch (e) { // We try/catch so we will catch if the the input fields can't be found // The error is automatically logged in Browsertime an rethrown here // We could have an alternative flow ... // else we can just let it cascade since it will catch later on and reported in // the HTML throw e; } };

BELOW ERROR

sitespeed.io NSE-Prod.js --multi --outputFolder /usr/local/var/www/sitespeed-result/NSE-Prod/$(date +\%Y-\%m-\%d-\%H-\%M-\%S) -n 1 [2020-03-14 10:49:47] INFO: Versions OS: darwin 18.7.0 nodejs: v13.8.0 sitespeed.io: 12.1.0 browsertime: 8.1.0 coach: 4.5.0 [2020-03-14 10:49:47] INFO: Running tests using Chrome - 1 iteration(s) [2020-03-14 10:49:49] INFO: Testing url https://www.verizonwireless.com iteration 1 [2020-03-14 10:50:01] INFO: Testing url https://www.verizonwireless.com/smartphones/ iteration 1 [2020-03-14 10:50:36] INFO: Testing url https://www.verizonwireless.com/smartphones/apple-iphone-11-pro-max/ iteration 1 [2020-03-14 10:51:20] INFO: Start to measure add2cart [2020-03-14 10:51:20] _INFO: https://www.verizonwireless.com/smartphones/apple-iphone-11-pro-max/ has been tested before within the same run, it will get an extra query parameter named browsertimerun. Make sure to use alias to keep track of the URLs [2020-03-14 10:51:21] ERROR: Could not add meta data to the HAR, miss page 3 [2020-03-14 10:51:21] INFO: https://www.verizonwireless.com 104 requests, backEndTime: 1.05s, firstPaint: 2.72s, DOMContentLoaded: 2.72s, Load: 6.11s, rumSpeedIndex: 5069 [2020-03-14 10:51:21] INFO: https://www.verizonwireless.com/smartphones/ 94 requests, backEndTime: 295ms, firstPaint: 13.22s, DOMContentLoaded: 12.93s, Load: 27.45s, rumSpeedIndex: 15397 [2020-03-14 10:51:21] INFO: https://www.verizonwireless.com/smartphones/apple-iphone-11-pro-max/ 96 requests, backEndTime: 848ms, firstPaint: 15.91s, DOMContentLoaded: 15.90s, Load: 37.65s, rumSpeedIndex: 29216 [2020-03-14 10:51:21] INFO: https://www.verizonwireless.com/smartphones/apple-iphone-11-pro-max/?browsertime_run=2 backEndTime: 848ms, firstPaint: 15.91s, DOMContentLoaded: 15.90s, Load: 37.65s, rumSpeedIndex: 29216 [2020-03-14 10:51:22] ERROR: Could not find the right index 3 for har for url https://www.verizonwireless.com/smartphones/apple-iphone-11-pro-max/?browsertime_run=2 [2020-03-14 10:51:22] ERROR: Error: PageIndex out of range at module.exports.pickAPage (/Users/v585896/.config/yarn/global/node_modules/webcoach/lib/har/harCutter.js:18:11) at Object.pickAPage (/Users/v585896/.config/yarn/global/node_modules/webcoach/lib/index.js:130:12) at Object.processMessage (/Users/v585896/.config/yarn/global/node_modules/sitespeed.io/lib/plugins/browsertime/index.js:229:29) [2020-03-14 10:51:24] INFO: HTML stored in /usr/local/var/www/sitespeed-result/NSE-Prod/2020-03-14-10-49-46

soulgalore commented 4 years ago

What happens when you add an item to the cart, do it generate a new page load?

softwareklinic commented 4 years ago

Its an overlay to enter the zipcode

image

softwareklinic commented 4 years ago

Below is the MOST ERROR free code - but cant measure ADD to cart --- acutally there is nothing to measure --- only after we enter zipcode & select whether you are new or existing it will take you to next page --- and then there is an action to add to cart

So, let me finish up the rest of the steps... since there is nothing to measure as of now and will let u know.

module.exports = async function(context, commands) { // Navigate to a URL, but do not measure the URL

try {
    // start measuring the metrics for home page
    await commands.measure.start('https://www.verizonwireless.com','homepage');

    // start measuing the metrics for SMartphones
    await commands.measure.start('https://www.verizonwireless.com/smartphones/','Smartphones');

    // start measuing the metrics for PDP
    await commands.measure.start('https://www.verizonwireless.com/smartphones/apple-iphone-11-pro-max/','PDP');

    // start measuring after clicking  on addtocart
    //await commands.js.run('for (let node of document.body.childNodes) { if (node.style) node.style.display = "none";}');
    //await commands.measure.start('add2cart');
    await commands.click.byXpath('//*[@id="ATC-Btn"]');
    //await commands.measure.stop('');

    // Stop and collect the metrics
    return;

} catch (e) { // We try/catch so we will catch if the the input fields can't be found // The error is automatically logged in Browsertime an rethrown here // We could have an alternative flow ... // else we can just let it cascade since it catched later on and reported in // the HTML throw e; } };

softwareklinic commented 4 years ago

WE ARE GOOD... THX A BUNCH...