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
Amit MohantyPosted Apr 8, 2024, 11:03 AM
I think, since you're using headless mode (--headless), the browser window won't be visible. So try once to remove the --headless argument or disable headless mode.
Jayraj ChhayaPosted Apr 8, 2024, 11:13 AM
it seems that the issue might be related to the ChromeOptions being used. The code is creating a ChromeOptions object and adding various arguments to it, such as "--headless=new" and "--mute-audio". However, it is commented out, so these options might not be applied when running the code.
To troubleshoot the issue, you can try the following steps:
Uncomment the lines of code that set the desired ChromeOptions. For example, remove the comments for the lines
options.AddArgument("--headless=new");andoptions.AddArgument("--mute-audio");.Check if there are any other options or settings that might affect the video display. For example, there might be additional options related to video playback or window size that need to be configured.
Verify that the video URL being used is correct. In the code snippet, the URL is set to
BASE_URLwith a video key of"2hAtzvoH_30". Make sure this URL is valid and points to the desired video.Check if there are any error messages or exceptions being thrown when running the code. If there are any, they might provide more information about the issue and help in troubleshooting.
Consider updating the ChromeDriver and Chrome browser to the latest versions. Sometimes, compatibility issues can arise between different versions of the browser and the driver.