browsertime icon indicating copy to clipboard operation
browsertime copied to clipboard

Cannot Measure Stats When Switching Browser Tabs

Open gfoxCartrawler opened this issue 6 years ago • 3 comments

Hi there,

New to Sitespeed here, I am trying to run a test where a page changes and opens in a new tab with a slightly different url. The test looks like it gathers stats for that page in the logs but I can't see the results in the reports.There are a few errors thrown in the logs though.

  • Exact how you run (the exact parameters)

docker run --rm -v "$(pwd)":/sitespeed.io sitespeedio/sitespeed.io:10.0.3flash/selenium/edreams-steps/scenario.js --config flash/config.json --multi--debug

  • Which version you are using 10.0.2 Have tried newer versions with the same result

  • OS (if you use Docker, report the base OS) Mac OS

  • BaseUrl https://rentacar.edreams.com/en-us?age=30&pickupDateTime=2020-03-01T10:00&returnDateTime=2020-03-30T12:30&clientID=313381&ct=MP&countryID=IE&curr=EUR&elID=711569439067570&residenceID=IE&pickupID=11&pickupName=Dublin-Airport&returnID=11&returnName=Dublin-Airport&#/searchcars

  • Config.json

{
  "utc": true,
  "gzipHAR": true,
  "html": {
    "fetchHARFiles": true,
    "showScript": true
  },
  "screenshot": {
    "type": "jpg"
  },
  "browsertime": {
    "iterations": 1,
    "browser": "chrome",
    "viewPort": "1440x1000",
    "pageCompleteWaitTime": 15000
  }
}

scenario.js

const FIRST_CAR_XPATH = '(//button[@data-auto-id=\'bookButton\'])[1]';


module.exports = async function(context, commands) {
  const {driver} = context.selenium;

  try {
    // Measure Landing Page
    await commands.measure.start('https://rentacar.edreams.com/en-us?age=30&pickupDateTime=2020-03-01T10:00&returnDateTime=2020-03-30T12:30&clientID=313381&ct=MP&countryID=IE&curr=EUR&elID=711569439067570&residenceID=IE&pickupID=11&pickupName=Dublin-Airport&returnID=11&returnName=Dublin-Airport#/searchcars', 'Odigeo_Landing_Page');
    // Measure Vehicle List
    await commands.wait.byId('searchCarsFormBtn-searchcars');
    await commands.measure.start('Odigeo_Vehicle_list');
    await commands.click.byIdAndWait('searchCarsFormBtn-searchcars');
    await commands.measure.stop();
    await commands.wait.byXpath(FIRST_CAR_XPATH, 20000);
    // Measure Car Page
    await commands.click.byXpath(FIRST_CAR_XPATH);
    await commands.wait.byTime(1000);
    const handles = await driver.getAllWindowHandles();
    context.log.info(`Number Of Handles ${handles.length}`);
    context.log.info(`Handle 2 Is: ${handles[1]}`);
    await driver.switchTo().window(handles[1]);
    await commands.measure.start('Odigeo_Car_Page');
    await commands.wait.byXpath(
      '//ct-vehicle-block-price-total-amount//div/div',
      10000
    );

    return commands.measure.stop();
  } catch (e) {
    throw e;
  }
};

Error Displayed:

[2019-10-04 16:03:04] ERROR: [plugin.browsertime] Could not find the right index 2 for har for url https://rentacar.edreams.com/en-us/book?age=30&clientID=313381&ct=MP&countryID=IE&curr=EUR&elID=711569439067570&pickupCountryCode=IE&pickupDateTime=2020-03-01T10%3A00&residenceID=IE&returnCountryCode=IE&returnDateTime=2020-03-30T12%3A30&pickupID=11&pickupName=Dublin%20-%20Airport&returnID=11&returnName=Dublin%20-%20Airport#/vehicle/1053481117 [2019-10-04 16:03:04] ERROR: [sitespeedio.queuehandler] 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:200:29) [2019-10-04 16:03:04] DEBUG: [plugin.browsertime] Generate summary metrics from Browsertime [2019-10-04 16:03:04] DEBUG: [plugin.coach] Generate summary metrics from the Coach [2019-10-04 16:03:04] DEBUG: [plugin.pagexray] Generate summary metrics from PageXray [2019-10-04 16:03:04] DEBUG: [sitespeedio.plugin.html] Render HTML for 2 page(s) [2019-10-04 16:03:04] DEBUG: [sitespeedio.plugin.html] Render summary page pages [2019-10-04 16:03:05] DEBUG: [sitespeedio.plugin.html] Render summary page index [2019-10-04 16:03:05] DEBUG: [sitespeedio.plugin.html] Render summary page detailed [2019-10-04 16:03:05] DEBUG: [sitespeedio.plugin.html] Render summary page domains [2019-10-04 16:03:05] DEBUG: [sitespeedio.plugin.html] Render summary page assets [2019-10-04 16:03:05] DEBUG: [sitespeedio.plugin.html] Render summary page toplist [2019-10-04 16:03:05] DEBUG: [sitespeedio.plugin.html] Render summary page scripts [2019-10-04 16:03:06] DEBUG: [sitespeedio.plugin.html] Render summary page help [2019-10-04 16:03:06] DEBUG: [sitespeedio.plugin.html] Render URL page index [2019-10-04 16:03:07] DEBUG: [sitespeedio.plugin.html] Render URL run page 1 [2019-10-04 16:03:08] DEBUG: [sitespeedio.plugin.html] Render URL page index [2019-10-04 16:03:08] DEBUG: [sitespeedio.plugin.html] Render URL run page 1 [2019-10-04 16:03:08] INFO: [sitespeedio.plugin.html] HTML stored in /sitespeed.io/sitespeed-result/scenario_js/2019-10-04-16-00-32

There are 3 measures but only 2 measures outputted to the report.

gfoxCartrawler avatar Oct 04 '19 16:10 gfoxCartrawler

Hi @gfoxCartrawler I think nothing is tested/prepared to test in other tabs so it would probably be a lot of things that needs to be fixed. For me it isn't so important but if you feel that you have the time to investigate and pinpoint/fix a PR for that it would be cool.

Best Peter

soulgalore avatar Oct 09 '19 20:10 soulgalore

This is an area of interest at Mozilla, in particular for Android browsing. Like other test frameworks, Browsertime initiates navigation via a window.location write.

We'd like to add the option to trigger the navigation from an app link (e.g. android Intent). However this creates a new tab in most browsers, making the metrics capture fail. I have made proof-of-concept app modifications that open app links in the same tab, but capturing metrics from arbitrary tabs in Browsertime still seems like best solution.

If we make progress on this, I'll update this bug.

acreskeyMoz avatar Apr 24 '20 13:04 acreskeyMoz

I think this is much work to get to work with Chrome?

soulgalore avatar Apr 12 '21 07:04 soulgalore

I think this is two different issues. Chrome (maybe Firefox too) will deprioritize work that happens in tabs that aren't active so, I think switching between tabs in a test scenario does not make sense. For the Mozilla use cases of starting testing with android Intent that would still make sense. I think we should open a separate issue for that.

soulgalore avatar Dec 17 '23 05:12 soulgalore