Stealth mode does not work in self-hosting

This issue has been tracked since 2022-10-07.

Describe the bug

Hello,
I'm trying to get stealth mode to work with no luck.
Whether I enable it or not the behavior seems the same.

To Reproduce

On a Debian machine, launch browserless via a docker-compose.yml file:

version: "3.9"

services:
  chrome:
    image: browserless/chrome:latest
    container_name: browserless
    restart: unless-stopped
    ports:
      - "3000:3000"
    expose:
      - "3000"
    environment:
      - DEFAULT_STEALTH=true
      - DEFAULT_BLOCK_ADS=true
      - DEFAULT_IGNORE_HTTPS_ERRORS=true
      - ENABLE_DEBUGGER=false
      - TOKEN=XXX

It starts correctly:

browserless  | 2022-10-07T12:43:36.256Z browserless:server {
browserless  |   CONNECTION_TIMEOUT: 60000,
browserless  |   MAX_CONCURRENT_SESSIONS: 10,
browserless  |   QUEUE_LENGTH: 10,
browserless  |   SINGLE_RUN: false,
browserless  |   CHROME_REFRESH_TIME: 1800000,
browserless  |   KEEP_ALIVE: false,
browserless  |   DEFAULT_BLOCK_ADS: true,
browserless  |   DEFAULT_HEADLESS: true,
browserless  |   DEFAULT_LAUNCH_ARGS: [],
browserless  |   DEFAULT_IGNORE_DEFAULT_ARGS: false,
browserless  |   DEFAULT_IGNORE_HTTPS_ERRORS: true,
browserless  |   DEFAULT_DUMPIO: false,
browserless  |   DEFAULT_STEALTH: true,
browserless  |   DEFAULT_USER_DATA_DIR: undefined,
browserless  |   PREBOOT_CHROME: false,
browserless  |   DEBUG: 'browserless*',
browserless  |   DISABLED_FEATURES: [],
browserless  |   ENABLE_CORS: false,
browserless  |   ENABLE_API_GET: false,
browserless  |   TOKEN: 'XXX',
browserless  |   ENABLE_HEAP_DUMP: false,
browserless  |   ALLOW_FILE_PROTOCOL: false,
browserless  |   DISABLE_AUTO_SET_DOWNLOAD_BEHAVIOR: false,
browserless  |   FUNCTION_BUILT_INS: [ 'url' ],
browserless  |   FUNCTION_ENV_VARS: [],
browserless  |   FUNCTION_ENABLE_INCOGNITO_MODE: false,
browserless  |   FUNCTION_EXTERNALS: [ 'lighthouse', 'node-pdftk', 'sharp' ],
browserless  |   WORKSPACE_DIR: '/usr/src/app/workspace',
browserless  |   WORKSPACE_DELETE_EXPIRED: false,
browserless  |   WORKSPACE_EXPIRE_DAYS: 30,
browserless  |   FAILED_HEALTH_URL: null,
browserless  |   QUEUE_ALERT_URL: null,
browserless  |   REJECT_ALERT_URL: null,
browserless  |   TIMEOUT_ALERT_URL: null,
browserless  |   ERROR_ALERT_URL: null,
browserless  |   SESSION_CHECK_FAIL_URL: null,
browserless  |   PRE_REQUEST_HEALTH_CHECK: false,
browserless  |   EXIT_ON_HEALTH_FAILURE: false,
browserless  |   MAX_CPU_PERCENT: 99,
browserless  |   MAX_MEMORY_PERCENT: 99,
browserless  |   METRICS_JSON_PATH: null,
browserless  |   HOST: '0.0.0.0',
browserless  |   PORT: 3000,
browserless  |   SOCKET_CLOSE_METHOD: 'http',
browserless  |   PROXY_URL: undefined,
browserless  |   MAX_PAYLOAD_SIZE: '5mb'
browserless  | } Final configuration

In Java, with the latest version of Selenium, execute:

    @SneakyThrows
    public static void main(String[] args) {

        var chromeOptions = new ChromeOptions();

        chromeOptions.addArguments("--no-sandbox");
        chromeOptions.addArguments("--headless");
        chromeOptions.addArguments("--disable-dev-shm-usage");
        chromeOptions.addArguments("--window-size=1920,1080");
        chromeOptions.setCapability("browserless:stealth", "true");
        chromeOptions.setCapability("browserless:token", "XXX");

        WebDriver driver = null;
        try {
            driver = new RemoteWebDriver(
                    new URL("http://xxxxxx:xxx/webdriver"),
                    chromeOptions
            );

            driver.get("https://bot.sannysoft.com/");

            Thread.sleep(5000);

            var scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
            FileUtils.moveFile(scrFile, new File("/Users/xxx/Desktop/" + scrFile.getName()));

        } finally {
            if (driver != null) {
                driver.quit();
            }
        }
    }

Result, stealth mode does not seem to work:

screenshot4795870280828869135

Expected behavior

The stealth mode works, when you look at the doc of https://github.com/berstend/puppeteer-extra/tree/master/packages/puppeteer-extra-plugin-stealth the result is quite different:

Capture d’écran 2022-10-07 à 14 46 56

Is there anything else that needs to be done to make this work?
Thank you.

Desktop:

  • OS: browserless server: Debian / Selenium client Macos M1
andyMrtnzP wrote this answer on 2022-10-18

Unfortunately, the Selenium client overrides the Puppeteer-stealth configuration on the server. That behavior would have to be set on the client, or to use a specific WebDriver library that doesn't override the server config.

More Details About Repo
Owner Name browserless
Repo Name chrome
Full Name browserless/chrome
Language TypeScript
Created Date 2017-11-17
Updated Date 2023-03-22
Star Count 5309
Watcher Count 47
Fork Count 516
Issue Count 29

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date