Hi
How to click Youtube like button using selenium . I am trying below code but not working
var like_btn = _driver.FindElement(By.XPath("//div[@id='info']//ytd-toggle-button-renderer[1]//a[1]//yt-icon-button[1]//button[1]//yt-icon[1]"));
Thanks
Hi
How to click Youtube like button using selenium . I am trying below code but not working
var like_btn = _driver.FindElement(By.XPath("//div[@id='info']//ytd-toggle-button-renderer[1]//a[1]//yt-icon-button[1]//button[1]//yt-icon[1]"));
Thanks
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Ramco RamcoPosted Apr 11, 2024, 5:05 AM
Hi Naimish
Below line can change every time.
Like this video along with 1,000 other people'
Thanks
Naimish MakwanaPosted Apr 11, 2024, 4:16 AM
The issue might be with the XPath you’re using to locate the like button. YouTube’s page structure can change frequently, and the XPath you’re using might no longer be valid.
Here’s a general approach to click the like button on a YouTube video using Selenium:
Please replace the
aria-labelvalue with the actual aria-label of the like button on your page. You can find this by inspecting the element in your browser.Thanks
Ramco RamcoPosted Apr 11, 2024, 3:25 AM
Hi Prasad
I am getting error - No such element found
Below is Script
Thanks
Prasad RaveendranPosted Apr 11, 2024, 3:04 AM
here is a more general method using CSS selector
This CSS selector targets the like button based on its structure, and then the
.click()function simulates a click action.Remember to check the current structure of the YouTube page to ensure the selector is accurate. If YouTube's structure changes frequently, you may need to update your selector accordingly.