Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for browser & context options via config #299

Closed
vigneshshanmugam opened this issue Jun 3, 2021 · 4 comments · Fixed by #317
Closed

Add support for browser & context options via config #299

vigneshshanmugam opened this issue Jun 3, 2021 · 4 comments · Fixed by #317
Labels
discussion Discuss about API changes, enhancements enhancement New feature or request

Comments

@vigneshshanmugam
Copy link
Member

vigneshshanmugam commented Jun 3, 2021

There are lot of ways we can configure the Playwright Browser and the context that is used to creating page objects in Playwright.

  1. Browser launch options - chromium.launch(options) - https://playwright.dev/docs/api/class-browsertype?_highlight=launch#browsertypelaunchoptions

  2. Browser Context options - browser.newContext(options) - https://playwright.dev/docs/api/class-browser#browsernewcontextoptions

To make it easier for users, We can introduce new flags in the synthetics.config.ts instead of adding CLI option for each and every config out there in the playwright.

This Proposal is as allow configuring browser and context options to the synthetic config in addition to the existing params support.

{
import {devices} from "playwright-chromium"

export default env => {
  return {
    params: {
      url: 'non-dev',
    },
    browser: {
      ...// browser options
    },
    context: {
      ...devices['Pixel 5'] // uses chromium
    }
  };
};
}

We could also merge them under playwrightOptions instead of separating them out and provide a validation that allowss only a restrictive list of options to keep things cleaner as well.

import { devices } from 'playwright-chromium';

export default env => {
  return {
    params: {
      url: 'non-dev',
    },
    playwrightOptions: {
      ignoreHttpsError: true,
      slowMo: true,
      timeout: 1000,
      ...devices['Pixel 5'],
      screenshots: true, // validate and throw error as we capture it ourselves
    },
  };
};

@andrewvc @paulb-elastic Thoughts?

@vigneshshanmugam vigneshshanmugam added discussion Discuss about API changes, enhancements enhancement New feature or request labels Jun 3, 2021
@andrewvc
Copy link
Contributor

andrewvc commented Jun 9, 2021

All these options should be overridable from heartbeat via flags etc.

@andrewvc
Copy link
Contributor

andrewvc commented Jun 9, 2021

We also need to think about the fleet UI for them

@vigneshshanmugam
Copy link
Member Author

Was thinking to mirror them in heartbeat.yml, something like pwOptions or browserOpts like how we do params. Another thing we can do from the heartbeat side is to create a synthetics.config.ts a temp file we can invoke for each test that would reduce the need of passing CLI args to the synthetic runner.

@paulb-elastic
Copy link
Contributor

I agree, having these options available to pass in gives us the flexibility to add config options as and when supported by newer versions of Playwright, without having to support them with specific params in HB/Synthetics.

Does it makes sense to initially have these as free form configuration options in the Fleet UI, and then add specific UI (e.g. checkbox) for some of these (e.g. ignore HTTPS errors, or device emulation), or will this create too much of a migration problem (mixed up config JSON and 'tick boxes'?

Maybe they are available like params are if you use heartbeat.yml in the first instance (nothing in Fleet), and then we add specific capabilities into the Fleet UI over time (e.g. device emulation etc.), as we view that configuration in the result UI as well (e.g. show the device type against the result).

/cc @drewpost @liciavale

@vigneshshanmugam vigneshshanmugam added [zube]: In Review and removed discussion Discuss about API changes, enhancements labels Jun 23, 2021
@zube zube bot added the discussion Discuss about API changes, enhancements label Jun 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Discuss about API changes, enhancements enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants