Ramco Ramco

Ramco Ramco

  • 464
  • 2.9k
  • 407.7k

Videos are not running

May 2 2024 9:32 AM

Hi 

  I have below code . Only first Video runs then Youtube suggested Video Starts. I want that all videos in array should get displayed.

foreach (var video in videos)
{
    _driver.Navigate().GoToUrl(video);

    var timeElement = _driver.FindElement(By.XPath(XPATH_TIME));
    string timeValue = timeElement.GetAttribute("innerText");

    // Parse the timeValue to TimeSpan
    if (TimeSpan.TryParse(timeValue, out TimeSpan videoDuration))
    {
        // Delay by the duration of the video
        await Task.Delay(videoDuration);
    }
    else
    {
        // Handle parsing error, maybe log it or use a default delay
        Console.WriteLine("Failed to parse video duration: " + timeValue);
        await Task.Delay(TimeSpan.FromMinutes(1)); // Default delay
    }
}

Thanks


Answers (4)