1

Been testing the Kameleo.LocalApiClient now whole day. Noticed something strange.

var client = new KameleoLocalApiClient(new Uri(KameleoBaseUrl));
client.SetRetryPolicy(null);

// Search Chrome Base Profiles
var baseProfileList = await client.SearchBaseProfilesAsync("desktop", "windows", "chrome", "ru-ru");

Random rnd = new Random();
var baseId = rnd.Next(1, baseProfileList.Count);

// Create a new profile with recommended settings
// Choose one of the Firefox BaseProfiles
// You can set your proxy up in the setProxy method
var requestBody = BuilderForCreateProfile
    .ForBaseProfile(baseProfileList[baseId].Id)
    .SetRecommendedDefaults()
    .SetProxy("http", new Server("zproxy.lum-superproxy.io", 22225, "lum-customer-joshua901-zone-zone2", "5inhblkgrzxj"))
    //.SetProxy("http", new Server("zproxy.lum-superproxy.io", 22225, "lum-customer-joshua901-zone-russiashared-ip-181.214.180.215", "lqoz0ee2hbvb"))
    .SetLauncher("chrome")
    //.SetScreen("--window-size", 500, 783)
    .Build();

var profile = await client.CreateProfileAsync(requestBody);

// Start the browser
await client.StartProfileAsync(profile.Id);

// Connect to the running browser instance using WebDriver
var uri = new Uri($"{KameleoBaseUrl}/webdriver");
var opts = new ChromeOptions();
opts.AddAdditionalOption("kameleo:profileId", profile.Id.ToString());


opts.AddExcludedArgument("enable-automation");
opts.AddArgument("--window-size=500,783");
opts.AddArgument("disable-infobars");
opts.AddArgument("--incongito");
opts.AddArgument("--disable-extensions");

opts.AddArgument("disable-gpu");
opts.AddArgument("headless");
opts.AddArgument("--ignore-certificate-errors");
opts.AddArgument("no-sandbox");
opts.AddArgument("--silent-launch");
opts.AddArgument("--no-startup-window");

//var webdriver = new RemoteWebDriver(uri, opts);
_driver = new RemoteWebDriver(uri, opts)

I want to add my additional ChromeOptions to my driver, especially be able to run things in "headless" mode.

Even if i define the ChromeOptions above and create the RemoteWebDriver with these options, the chrome browser does still popup and not run as headless.

How come and how do i add my additional options?

1 Answers1

1
  • The browser is started by Kameleo
  • The RemoteWebDriver is not starting any browser, just connecting to the already started browser

Because of these, you cannot pass any arguments to the browser with the RemoteWebDriver's options.

There is way to provide additional web driver options. There is a POST /profiles/{guid}/start endpoint which can process additional arguments, options, and preferences when Kameleo is starting the browser. See the documentation or see the example code.

await client.StartProfileWithWebDriverSettingsAsync(profile.Id, new WebDriverSettings
{
    Arguments = new List<string> { "mute-audio" },
    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"),
    }
});

There are arguments that are not supported and that may cause issues so it is better to contact the team about the arguments.

For example:

opts.AddArgument("--disable-extensions");

This cannot be added, since Kameleo's extension is needed in the browser. If you remove it, the spoofing won't work.

I see you want to use this flag as well:

opts.AddArgument("disable-gpu");

You can simply set WebGL to Block. IT will result in the same.

Currently, there is no opportunity to start the browser in headless mode. But there will be a solution soon.

stephen979
  • 23
  • 5