Hi
static async Task Start() { //_isRunning = true; //btnStop.Enabled = _isRunning; //btnRun.Enabled = !_isRunning; var options = new ChromeOptions(); //if (chkHeadless.Checked) options.AddArgument("--headless=new"); //if (chkMuteAudio.Checked) options.AddArgument("--mute-audio"); //if (chkPreventDetection.Checked) { options.AddArgument("--incognito"); options.AddArgument("disable-infobars"); options.AddExcludedArgument("enable-automation"); options.AddAdditionalChromeOption("useAutomationExtension", false); } var service = ChromeDriverService.CreateDefaultService(); service.HideCommandPromptWindow = true; _driver = new ChromeDriver(service, options); _driver .Manage() .Window .Size = new Size(1024, 768); var isMuted = true; // chkMuteAudio.Checked; var randomDelay = true; // chkDelay.Checked; var videoKey = true; // txtVideoKey.Text; var instances = 5; // updnInstances.Value; for (var count = 1; count <= instances; count++) { //if (!_isRunning) // return; await Task.Run(async () => { //if (!_isRunning) // return; //OpenVideo(videoKey, isMuted); _driver .Navigate() .GoToUrl($"{BASE_URL}?v={"2hAtzvoH_30"}"); var videoControls = new WebDriverWait(_driver, TimeSpan.FromSeconds(10)) .Until(driver => driver.FindElement(By.ClassName("ytp-chrome-controls"))); var action = new Actions(_driver); action .MoveToElement(videoControls) .Perform(); if (randomDelay) await Task.Delay(_random.Next(5, 10) * 1000); }); } } }
Thanks