i'm trying to locate the subscribe button in Youtube then click it, but i'm not able to do that.
My actual code :
public void start()
{
// Initialize the instance
driver = new ChromeDriver();
// Navigate to the url
driver.Navigate().GoToUrl("https://www.youtube.com/channel/UCaJBePyIsBIp4MtVFpPbtJg");
// 1.5
Thread.Sleep(1500);
// Find and Click on button
driver.FindElement(By.CssSelector(".style-scope.ytd-button-renderer.style-destructive.size-default")).Click();
}
My two methods tried :
// METHOD 1
driver.FindElement(By.CssSelector("style-scope ytd-button-renderer style-destructive size-default")).Click();
renderer').click()");
// METHOD 2
IJavaScriptExecutor jse = (IJavaScriptExecutor)driver;
jse.ExecuteScript("document.getElementById('#subscribe-button > ytd-button-renderer').click()");