How to pass profile preferences to the browser?

  • Created

We recommend that you read the Getting started with Kameleo Automation article before reading this one.

With Kameleo you can fine-tune the browsers and you can pass most of the options, and capabilities that are supported by Selenium. You need to start the browser with POST /profiles/{guid}/start endpoint and pass preferences and additionalOptions to it. See the documentation on SwaggerHub.

You can set a list of preferences for browsers at startup. In the case of Chromium-based options, it will be a user profile preference. In the case of Firefox profiles, it will be a preference. You can also set a list of additional WebDriver options at startup. It is applicable for both Chromium-based browsers and for firefox.

This way you can simply save network traffic by disabling images.

  • await client.startProfileWithWebDriverSettings(profile.id, {
      body: {
        preferences: [
          {
            key: 'profile.managed_default_content_settings.images',
            value: 2,
          },
          {
            key: 'profile.password_manager_enabled.images',
            value: 2,
          },
        ],
        additionalOptions: [
          {
            key: 'pageLoadStrategy',
            value: 'eager',
          },
        ],
      },
    });

    See full example here.

  • await client.StartProfileWithWebDriverSettingsAsync(profile.Id, new WebDriverSettings
    {
      Preferences = new List<Preference>
      {
        new Preference("profile.managed_default_content_settings.images", 2),
        new Preference("profile.password_manager_enabled.images", 2),
      },
      AdditionalOptions = new List<Preference>
      {
        new Preference("pageLoadStrategy", "eager"),
      }
    });

    See full example here.

  • client.start_profile_with_web_driver_settings(profile.id, WebDriverSettings(
      preferences=[
        Preference(key='profile.managed_default_content_settings.images', value=2),
        Preference(key='profile.password_manager_enabled.images', value=2)
      ],
      additional_options=[
        Preference(key="pageLoadStrategy", value="eager")
      ]
    ))

    See full example here.

Please note that some preferences may be blacklisted as they may interfere with Kameleo’s spoofing mechanism.

Was this article helpful?

0 out of 0 found this helpful