Selenium.WebDriver.UndetectedChromeDriver icon indicating copy to clipboard operation
Selenium.WebDriver.UndetectedChromeDriver copied to clipboard

[HELP!] how to use BinaryLocation ????

Open duongbinh214 opened this issue 3 years ago • 4 comments

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

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

duongbinh214 avatar Nov 08 '22 01:11 duongbinh214

https://github.com/emre-gon/Selenium.WebDriver.UndetectedChromeDriver/issues/15#issue-1434686372 l've the asked the same question before

RifHut avatar Nov 08 '22 09:11 RifHut

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) https://github.com/emre-gon/Selenium.WebDriver.UndetectedChromeDriver/blob/e5bffe495f062010eef381249b83510b0c55ffce/Selenium.WebDriver.UndetectedChromeDriver/UndetectedChromeDriver.cs#L185

RifHut avatar Nov 09 '22 14:11 RifHut

@emre-gon

RifHut avatar Nov 10 '22 19:11 RifHut

` 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

RifHut avatar Nov 11 '22 12:11 RifHut