It looks like the ChromeDriver version you're using is not compatible with your current version of Chrome. You need to update your ChromeDriver to match your Chrome browser version. Here’s how you can do it:
-
Download the Compatible ChromeDriver:
- Visit the ChromeDriver download page.
- Find the version of ChromeDriver that matches your Chrome browser version (127.0.6533.89).
-
Update ChromeDriver in Your Project:
- Replace the existing
chromedriver.exe
file in your project or system with the newly downloaded one.
- Ensure that the
chromedriver.exe
is in your project directory or in a location that is included in your system's PATH environment variable.
-
Verify Compatibility:
- Ensure that the
ChromeDriver
version and the Chrome
browser version are both up-to-date and compatible with each other.
Here's an updated version of your method to include proper disposal of WebDriver
:
static async Task SingleVideo0()
{
using (IWebDriver driver = new ChromeDriver())
{
driver.Navigate().GoToUrl("https://www.google.com");
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
var playButtons = wait.Until(_driver => _driver.FindElements(By.ClassName("video-play-button")));
foreach (var playButton in playButtons)
{
playButton.Click();
await Task.Delay(2000); // Use Task.Delay for asynchronous sleep
}
}
}
By using await Task.Delay
, you ensure that the sleep operation is asynchronous and won't block the thread.