Web browser automation - Automating repetitive browsing tasks

Kameleo changes the browser fingerprint so you will be able to stay undetected. Why not automate your tasks in the browser with it? This makes it possible to manage multiple online accounts automatically from one machine. In Kameleo v2 we provide a Local API to manage the application from code through a REST API and we made it possible to control the browser from Selenium without websites noticing it (or Puppeteer).

Browser automation in Kameleo v2

Once you start Kameleo.CLI.exe on your PC, a local API will be available that you can use to automate all tasks in Kameleo. You can simply call the Local REST API from your code (C#, NodeJS, Java, Python, Javascript, etc.) and perform everything you can do on the graphical interface, such as creating, starting, and saving a profile.

To help your work we have created a NuGet package for .NET C# developers and an NPM package for Javascript / NodeJS developers. With these packages, you can start a Kameleo profile with ~10 lines of code. Please see the README of the above packages for quickstart guides. Please also consider checking our GitHub Repository with plenty of examples.


Once the browser is started for the profile you can control it through the W3C WebDriver protocol by simply calling Selenium command from your code. And websites won't notice the presence of WebDriver. See the above packages' README files for examples. (There is a workaround for Puppeteer as well, but the recommended solution is using Selenium)

Browser automation in Kameleo v1.9.7

We are already developing the browser automation features of Kameleo. You won’t have to install any plugin to the browser, you will be able to write high-level automation code and Kameleo will do the work for you. We also plan to automate Kameleo’s operations, like creating a new profile automatically.

Right now it is possible to connect to the Selenium Driver after the browser is started by Kameleo. This way you can automate tasks in the browser by writing code in any language (For Example C#, Java, NodeJS, Python, Ruby, Perl, Javascript).

You simply have to enable External Selenium Connections in the App Settings.


Then when you launch a desktop profile, the connection details will be printed by Kameleo.


Once the browser is running you can simply connect to the Selenium Driver from your code. Then you will be able to perform actions automatically in the browser. For example:

  • Automatically watch YouTube videos and comment
  • Automatically browse Facebook and like photos

Here we provide some examples.


const webdriver = require('selenium-webdriver')
const http= require('selenium-webdriver/http')

void async function() {
// Replace with your session ID and selenium url
let sessionId = '575188848a13bb780c4ad12acbfc6f87';
let url = 'http://localhost:62542';

let driver = new webdriver.WebDriver(
new http.Executor(Promise.resolve(url)
url => new http.HttpClient(url, null, null))

await driver.get('https://help.kameleo.io');

let searchbars = await driver.findElements(webdriver.By.xpath('//input[@type="search"]'));
for (const searchbar of searchbars) {
if (await searchbar.isDisplayed()) {
await searchbar.sendKeys('automation');
await searchbar.sendKeys(webdriver.Key.ENTER);

let xPath = "//a[contains(text(),'browser automation')]";
await driver.findElement(webdriver.By.xpath(xPath)).click();

This script will open our knowledge base and search for automation articles and open the first one.


using System;
using System.Collections.Generic;
using OpenQA.Selenium;
using OpenQA.Selenium.Remote;

namespace KameleoAutomationExample
    class Program
        static void Main(string[] args)
            // Replace with your session ID and selenium url
            var url = "http://localhost:53936";
            var sessionId = "208aa270ea366fdd4dd2d8baecc193b3";

            var uri = new Uri(url);
            AttachableRemoteWebDriver.SessionIdToAttach = sessionId; // This has to be done before the object instantiation
            var webDriver = new AttachableRemoteWebDriver(uri, new RemoteSessionSettings()); // You can instantiate with a specific driver options as well

          webDriver.FindElement(By.XPath("//a[contains(text(),'browser automation')]")).Click();         }     }     public class AttachableRemoteWebDriver : RemoteWebDriver     {         public static string SessionIdToAttach;         public AttachableRemoteWebDriver(Uri remoteAddress, DriverOptions driverOptions)             : base(remoteAddress, driverOptions)         {         }         public AttachableRemoteWebDriver(Uri remoteAddress, RemoteSessionSettings remoteSessionSettings)             : base(remoteAddress, remoteSessionSettings)         {         }         protected override Response Execute(string driverCommandToExecute, Dictionary<string, object> parameters)         {             if (driverCommandToExecute == DriverCommand.NewSession)             {                 return new Response                {                    SessionId = SessionIdToAttach                };             }             else             {                 return base.Execute(driverCommandToExecute, parameters);             }         }     } }

This script will open our knowledge base and open the article about automation.


We haven’t created any automation code in Java yet. If you do please send us a code snippet in email and we will provide you a one-month free subscription. The code should open our knowledgebase and search for browser automation.


You will have to install selenium by running this command:

pip install -U selenium

Here is the script that will open our knowledge base and search for automation articles and open the first one.

def Kameleo(port, sessionID):
from selenium import webdriver
from selenium.webdriver.remote.webdriver import WebDriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.remote.file_detector import UselessFileDetector

def attach_to_session(executor_url, session_id):
original_execute = WebDriver.execute
def new_command_execute(self, command, params=None):
if command == "newSession":
# Mock the response
return {'success': 0, 'value': None, 'sessionId': session_id}
return original_execute(self, command, params)
# Patch the function before creating the driver object
WebDriver.execute = new_command_execute
driver = webdriver.Remote(command_executor=executor_url, desired_capabilities={}, file_detector=UselessFileDetector())
driver.session_id = session_id
# Replace the patched function with original function
WebDriver.execute = original_execute
return driver

driver = attach_to_session('' + str(port), str(sessionID))

searchbars = driver.find_elements_by_xpath('//input[@type="search"]')

i = 0
while i < len(searchbars):
if searchbars[i].is_displayed() == True:
i += 1

driver.find_element_by_xpath('//a[contains(text(),"browser automation")]').click()

if __name__ == '__main__':
# define your port and sessionID here
port = '62542'
sessionID = '575188848a13bb780c4ad12acbfc6f87'

Future developments

This selenium automation feature of Kameleo is requested by our community. We plan to build even more useful features for you. We would like to provide a solution where you can automate Kameleo itself as well. For example:

  • Automatically open a profile
  • Automatically create a profile
  • Automatically start a profile

Let us know if you have any comments about it in email (hello [at] kameleo [dot] io). We are also interested in your comments if you agree with our current plan. Also if you have further requests, comments, etc. We may like your idea and build this great software for your needs. Please provide as much information as possible.

One idea is to provide a REST interface where you can connect to Kameleo and create, save, load, clone, start, stop profiles automatically through it. You will be able to connect to the browser thru selenium as well.

The other idea is to let users import a well know script that will perform automatic operations in Kameleo like starting one or multiple profiles and navigating in the browser.

We will keep you updated about our plan. Please contact us in email if you have further comments on it.

Browser Automation with add-ons

A possible workaround to automatically perform operations in the browser with Kameleo is to install add-ons to the browser. Our recommendation is Kantu. It is available for Chrome and for Firefox.

You can simply install this add-on to the profile’s browser where you want to perform operations automatically.

With Kantu you can record what you do in the browser and it will generate code for you. You can edit and import the code any time and Kantu will perform everything automatically.

How to use Kantu

First, you will see an empty workspace in the table view and in the source view.


If you click on the record button the program will start to write what you do in the browser.


You can see the generated code at the Source View. It is a JSON code, so you can edit the code if you do not like the record mode.


This example code will search our knowledgebase for articles about ‘proxy’ and open one of them.

"Name": "test",
"CreationDate": "1970-1-1",
"Commands": [
    "Command": "clickAndWait",
    "Target": "link=Knowledgebase",
    "Value": ""
    "Command": "click",
    "Target": "xpath=//*[@id=\"searchform\"]/div/label",
    "Value": ""
    "Command": "type",
    "Target": "id=s",
    "Value": "proxy"
    "Command": "clickAndWait",
    "Target": "id=searchsubmit",
    "Value": ""
    "Command": "click",
    "Target": "link=Why is a proxy important?",
    "Value": ""

After the code is done the browser can reproduce what is in the code. You have to click on the Play Macro button.


Kantu can read and recognize images and text inside canvas elements, images, and videos. Kantu can resize the browser’s window.

Was this article helpful?
4 out of 4 found this helpful