Using Kameleo with Selenium framework

  • Created

When you are working with Kameleo and Selenium:

  1. You will use Kameleo Local API to manage your virtual browser profiles and launch Kameleo's built-in browsers.
  2. You will use Selenium to drive the browser with the W3C protocol.

Automate any browsing activity with Selenium. We'll help with keeping your scripts undetected by the sites you're visiting so that they won't see automation tools in use. Let's see how.

Before reading this article, we recommend reading the Getting started with Kameleo Automation article.

Install Selenium

To work with the Selenium framework, you need to install its official library.

  • npm i selenium-webdriver
  • Install-Package Selenium.WebDriver -Version 4.1.0
  • pip install selenium

Connect Selenium to a Kameleo profile

  1. Follow this guide for starting a profile from your script. Once the profile is up and running, you can move on to the next step to control it with Selenium commands.
  2. You need to build a WebDriver instance and pass the profile's unique ID as a capability named kameleo:profileId. In the case of some Selenium client library implementations, you also have to set the browserName capability, but the value can be anything.
    • const { Builder } = require('selenium-webdriver');
      const builder = new Builder()
          browserName: 'Kameleo',
      const webdriver = await;
    • using OpenQA.Selenium;
      using OpenQA.Selenium.Chrome;
      using OpenQA.Selenium.Remote;
      var uri = new Uri($"http://localhost:{KameleoPort}/webdriver");
      var opts = new ChromeOptions();
      opts.AddAdditionalOption("kameleo:profileId", profile.Id.ToString());
      var webdriver = new RemoteWebDriver(uri, opts);
    • from selenium import webdriver
      options = webdriver.ChromeOptions()
      driver = webdriver.Remote(
  3. Then you can use any WebDriver command to drive the browser, for example:
    • await webdriver.get("");
    • webdriver.Navigate().GoToUrl("");
    • driver.get('')
  4. Make sure to stop the browser. The virtual browser profile is then stored in you local workspace. Optionally you can export it to a .kameleo file, so you can load it later on another computer as well. Or simply you can delete the profile from Kameleo's workspace once you don't need it anymore. This way, you can keep your resource usage low.
    • await client.stopProfile(;
      await client.exportProfile(, { body: { path: `${__dirname}\\test.kameleo` } }); // optional
      await client.deleteProfile(; // optional
    • await client.StopProfileAsync(profile.Id);
      await client.ExportProfileAsync(profile.Id, new SaveProfileRequest(
        Path.Combine(Environment.CurrentDirectory,"test.kameleo"))); // optional
      await client.DeleteProfileAsync(profile.Id); // optional
    • client.stop_profile(
      path = f'{os.path.dirname(os.path.realpath(__file__))}\\test.kameleo'
      result = client.export_profile(, body=SaveProfileRequest(path=path)) # optional
      client.delete_profile(; # optional

If you want to see the full example code, click any of the links below:

Was this article helpful?

2 out of 5 found this helpful