Selenium.WebDriver.UndetectedChromeDriver
Selenium.WebDriver.UndetectedChromeDriver copied to clipboard
How to start using?
Please someone give me an example of how to start. I'm getting errors and have no idea how to start. Can anyone suggest a code to get started that works?
My Code
using OpenQA.Selenium.Chrome;
using Selenium.WebDriver.UndetectedChromeDriver;
using Sl.Selenium.Extensions.Chrome;
using System.Reflection;
namespace Botnet
{
internal class Program
{
static void Main(string[] args)
{
ChromeOptions options = new ChromeOptions();
options.BinaryLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\ChromeDrivers\undetected_chromedriver.exe";
UndetectedChromeDriver.ENABLE_PATCHER = true;
using (var driver = UndetectedChromeDriver.Instance("profile_name", options, TimeSpan.FromSeconds(10)))
{
driver.GoTo("https://nowsecure.nl");
driver.RandomWait(5, 7);
if (driver.GetTextOf("h1") == "OH YEAH, you passed!")
{
Console.WriteLine("OH YEAH, you passed!");
}
else
{
Console.WriteLine("Did not work!");
}
}
Console.ReadLine();
}
}
}

Error:
OpenQA.Selenium.WebDriverException: 'unknown error: Chrome failed to start: was killed.
(unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location
C:\Users\guilh\OneDrive\Projetos\.NET\bot-net\bot-net\bin\Debug\net6.0\ChromeDrivers\undetected_chromedriver.exe
is no longer running, so ChromeDriver is assuming that Chrome has crashed.)'

I added both chrome and chromedriver to PATH and then just using UndetectedChromeDriver.Instance() worked but it is still getting detected.
That sad. It looks like that repository is broken.