facebook / memlab

A framework for finding JavaScript memory leaks and analyzing heap snapshots
https://facebook.github.io/memlab/
MIT License
4.28k stars 115 forks source link

Browser is not supported error #32

Open KomalAgarwal1 opened 1 year ago

KomalAgarwal1 commented 1 year ago

Hi Team,

I am getting unsupported browser issue during initial launch, while trying to run memlab on an application. (Ran the script in headful mode). Observed the same script is working in Puppeteer(stand alone version) for the same chromium version. Chrome Version is 101.0.4950.0

Tried using below code in setup function but it did'nt help: async function setup() { const browser = await puppeteer.launch({ product: "firefox" }); const page = await browser.newPage(); }

Can you please confirm if there is any way to select a different browser via some code in script or in runtime while executing using CLI?

Below is the screenshot of error : image

Error on console: page-load(baseline)[s1] > action-on-page(target)[s2] > revert(final)[s3] interaction fail, making 2 more attempt(s)... interaction fail, making 1 more attempt(s)... Use memlab help or memlab <COMMAND> -h to get helper text interaction fail

JacksonGL commented 1 year ago

@KomalAgarwal1 MemLab doesn't support Firefox for now. The setup callback has a page parameter, please use that instead of creating your own, otherwise MemLab cannot navigate through the page or take heap snapshots.

KomalAgarwal1 commented 1 year ago

@JacksonGL I have tried with page parameter also, but its giving the same error. Is there any other way I can use to navigate the application?

JacksonGL commented 1 year ago

@KomalAgarwal1 Can you share the scenario file (with the page parameter)?

Observed the same script is working in Puppeteer(stand alone version) for the same chromium version.

What kind of chromium + Puppeteer (besides stand alone version) are you using?

KomalAgarwal1 commented 1 year ago

Hi @JacksonGL PFA script for your reference. testfile.txt

Can you please elaborate on below? What kind of chromium + Puppeteer (besides stand alone version) are you using?

JacksonGL commented 1 year ago

@KomalAgarwal1 earlier you mentioned:

Observed the same script is working in Puppeteer(stand alone version) for the same chromium version. Chrome Version is 101.0.4950.0

So I was asking which puppeteer + chromium version you are using that is not working for the script?

JacksonGL commented 1 year ago

@KomalAgarwal1 Also thanks for sharing the script, I see it no longer contains the await puppeteer.launch({ product: "firefox" }); statement. Is it working right now? Or do you still get the some errors?

Tip: when the memlab run fails, rerun memlab with -v to get more debug information

KomalAgarwal1 commented 1 year ago

@JacksonGL No the script is still not working, it gives the same error as shown in screenshot.

Please see detailed logging below:

Xvfb supports: false Xvfb: false { "_browserVersion": "Chrome/101.0.4950.0", "_puppeteerConfig": { "headless": false, "devtools": false, "ignoreHTTPSErrors": true, "ignoreDefaultArgs": [ "--disable-extensions" ], "args": [ "--no-sandbox", "--disable-notifications", "--use-fake-ui-for-media-stream", "--use-fake-device-for-media-stream", "--js-flags=\"--no-move-object-start\"", "--enable-precise-memory-info", "browser-test" ], "defaultViewport": { "width": 1680, "height": 1080, "deviceScaleFactor": 1 } }, "_consoleMessages": [] } Browser version: Chrome/101.0.4950.0 Node.js version: v16.17.0 Start tracking JS heap Fri Sep 23 2022 21:48:21 GMT+0530 (India Standard Time) [1/3] visiting page-load (baseline) page-load(baseline)[s1] > action-on-page(target)[s2] > revert(final)[s3] url: https://hostportalperf.cbrehost.com/login loading: https://hostportalperf.cbrehost.com/login URL changed: Expected: https://hostportalperf.cbrehost.com/login

Actual: https://hostportalperf.cbrehost.com/browserError.html

Error: No node found for selector: [id=onetrust-accept-btn-handler] at assert () at DOMWorld.click () at processTicksAndRejections (node:internal/process/task_queues:96:5) at async setup () interaction fail

KomalAgarwal1 commented 1 year ago

I was asking which puppeteer + chromium version you are using that is not working for the script?

Puppeteer version: 13.7.0 Chrome version: 101.0.4950.0

JacksonGL commented 1 year ago

@KomalAgarwal1 Can you share the full error message? (including the interaction fail, making 1 more attempt(s)... part)

I was asking which puppeteer + chromium version you are using that is not working for the script? Puppeteer version: 13.7.0 Chrome version: 101.0.4950.0

If I understand correctly, you had a standalone puppeteer script (without MemLab) that did the same interactions, and it worked. Is that right?

KomalAgarwal1 commented 1 year ago

@JacksonGL The one I have shared in above comment is the complete error message.

If I understand correctly, you had a standalone puppeteer script (without MemLab) that did the same interactions, and it worked. Is that right? Correct

JacksonGL commented 1 year ago

Ah ok, I thought the error message was incomplete because of the line separator.

This part is interesting:

Expected: https://hostportalperf.cbrehost.com/login
Actual: https://hostportalperf.cbrehost.com/browserError.html

I guess https://hostportalperf.cbrehost.com has some sort of user agent checking for the browser vendor and version.

KomalAgarwal1 commented 1 year ago

Ah ok, I thought the error message was incomplete because of the line separator.

This part is interesting:

Expected: https://hostportalperf.cbrehost.com/login
Actual: https://hostportalperf.cbrehost.com/browserError.html

I guess https://hostportalperf.cbrehost.com has some sort of user agent checking for the browser vendor and version.

If that is the case, Is there a way using which I can pass the user-agent from memlab script?

KomalAgarwal1 commented 1 year ago

Also, the browser version is same from both memlab and puppeteer(stand alone)

JacksonGL commented 1 year ago

yeah I know, memlab sets a default user agent string here: https://github.com/facebookincubator/memlab/blob/main/packages/core/src/lib/Constant.ts#L21

For now, there is no option to set the user agent in MemLab CLI (we can add one).

To verify the theory about user agent checking, you can check out memlab git repo, change the user agent in the link above, build with npm install && npm run build and run with the build from Git repo:

node ./packages/memlab/bin/memlab run --scenario <YOUR SCENARIO FILE>
KomalAgarwal1 commented 1 year ago

@JacksonGL Tried the same steps as you suggested. Changed defauft user agent as below in constant.ts file:

defaultUserAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 " + "(KHTML, like Gecko) Chrome/ 105.0.0.0 Safari / 537.36",

I am getting error in build step. Attaching the error log for the same

error.txt

JacksonGL commented 1 year ago

@KomalAgarwal1 looks like you are building on Windows, please build with Git Bash

KomalAgarwal1 commented 1 year ago

@JacksonGL
After changing defaultUserAgent to "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36" and running npm build in git bash. It is able to launch the app but partially.

Actual behavior of app: This page generates a login page and gives option to enter user details but this isn't loading properly. Please have a look below:

Log details : logging.txt

image

Ideally the page should have looked like this: image

JacksonGL commented 1 year ago

@KomalAgarwal1 That's strange.

I would recommend a few things to try:

  1. Set defaultUserAgent to null. In that case MemLab will use Chromium's default userAgent.
  2. When you run memlab run command also add the --debug and --headful option, which will pause execution after every step so that you can use Chromium's DevTools to see what happens in the browser page.
KomalAgarwal1 commented 1 year ago

@KomalAgarwal1 That's strange.

I would recommend a few things to try:

  1. Set defaultUserAgent to null. In that case MemLab will use Chromium's default userAgent.
  2. When you run memlab run command also add the --debug and --headful option, which will pause execution after every step so that you can use Chromium's DevTools to see what happens in the browser page.

@JacksonGL These steps didn't helped much because I see the same behavior of the application. It is not loading the Email and Login area.

JacksonGL commented 1 year ago

@KomalAgarwal1 Here are all the puppeteer configs in MemLab, you can start by removing all of the configs and add them back one by one and see which puppeteer config doesn't work with the site under test:

https://github.com/facebook/memlab/blob/main/packages/core/src/lib/Config.ts#L270