Giter Site home page Giter Site logo

Comments (4)

RifHut avatar RifHut commented on May 25, 2024 2

` bool HL = (data.GlobalSettings.Selenium.Headless || data.ConfigSettings.ForceHeadless);
bool PATCHER = data.ConfigSettings.EnableUndetectChromeDriver;
/* Profile data string of the given path */
string PATH = data.ConfigSettings.ProfilePath + @"";
Match PROFILE = Regex.Match(data.Data.Data, @"([\w.-]+@[\w.-]+)");
string full_path = PATH + PROFILE;
data.Log(new LogEntry("Opening browser...", Colors.White));
string ProfileName = "";
switch (data.GlobalSettings.Selenium.Browser)
{

                case BrowserType.Chrome:
                    try
                    {
                        UndetectedChromeDriver.ENABLE_PATCHER = PATCHER; //True or False
                        ChromeDriverParameters chromeDriverParameters = new ChromeDriverParameters();
                        ChromeOptions chromeop = new ChromeOptions();
                        chromeop.BinaryLocation = data.GlobalSettings.Selenium.ChromeBinaryLocation;
                        chromeDriverParameters.Timeout = new TimeSpan(0, 0, 22);
                        //chromeDriverParameters.DriverArguments = Args;
                        //chromeDriverParameters.ExcludedArguments = Exc;
                        //chromeDriverParameters.Headless = HL; //True or False
                        if (data.ConfigSettings.DefaultProfileDirectory == false)
                        {
                            ProfileName = chromeDriverParameters.ProfileName = full_path;
                            //chromeop.AddArgument("user-data-dir=" + full_path);
                            if (!Directory.Exists(full_path))
                            {
                                Directory.CreateDirectory(full_path);
                            }
                            data.Log(new LogEntry($"Browser DATAPATH : {full_path} and his profile : {data.Data.Data}", Colors.White));
                        }
                        if (data.ConfigSettings.DefaultProfileDirectory == true) {
                            ProfileName = chromeDriverParameters.ProfileName = full_path + "\\Default";
                        }
                        if (data.UseProxies) chromeop.AddArgument("--proxy-server=" + data.Proxy.Type.ToString().ToLower() + "://" + data.Proxy.Proxy);
                        if (!chromeop.Arguments.Any(it => it.Contains("--lang")))
                        {
                            var language = CultureInfo.CurrentCulture.Name;
                            chromeop.AddArgument($"--lang={language}");
                            data.Log(new LogEntry($"Testing this argument --lang={language}", Colors.White));
                        }
                        if (data.ConfigSettings.RandomUA) chromeop.AddArgument("--user-agent=" + UserAgent.Random(data.random));
                        else if (data.ConfigSettings.CustomUserAgent != string.Empty) chromeop.AddArgument("--user-agent=" + data.ConfigSettings.CustomUserAgent);
                        if (data.ConfigSettings.CustomCMDArgs != string.Empty) chromeop.AddArgument(data.ConfigSettings.CustomCMDArgs);
                        if (data.ConfigSettings.CMDArgs != string.Empty) chromeop.AddArgument(data.ConfigSettings.CMDArgs);

                        try
                        {
                            data.Driver = UndetectedChromeDriver.Instance(ProfileName, chromeop, chromeDriverParameters.Timeout);
                        }
                        catch
                        {
                            break;
                        }`

Try this Work Fine :) !
@duongbinh214

from selenium.webdriver.undetectedchromedriver.

RifHut avatar RifHut commented on May 25, 2024

#15 (comment) l've the asked the same question before

from selenium.webdriver.undetectedchromedriver.

RifHut avatar RifHut commented on May 25, 2024

how to use ChromeOptions options = new ChromeOptions(); options.BinaryLocation = pathChromes;

Thanks !!!!!!!!!!!!!!!!!!!

Try this at the end to call the object "options"

There are two options just check the source :
public static SlDriver Instance(string ProfileName, ChromeOptions ChromeOptions)

public static SlDriver Instance(string ProfileName, ChromeOptions ChromeOptions, TimeSpan Timeout)

from selenium.webdriver.undetectedchromedriver.

RifHut avatar RifHut commented on May 25, 2024

@emre-gon

from selenium.webdriver.undetectedchromedriver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.