C# selenium youtube shorts

John Konev

Regular Member
Joined
Aug 28, 2019
Messages
222
Reaction score
134
Does anyone here has idea how can I get the correct html element for the youtube comment textbox. Tried approaching it multiple ways but seems that I can't get the right xpath of the element that I am looking for.


Screenshot 2022-03-21 160336.png
 
Did you try opening it in a normal browser, right clicking on the textarea and copying the full xpath? If that does not work, chances are, it keeps changing every view.
 
Did you try opening it in a normal browser, right clicking on the textarea and copying the full xpath? If that does not work, chances are, it keeps changing every view.
Yeah, tried that already but no luck.
 
when you are trying to find this box using selenium have you logged in? The box rendered when you are not logged in is different from what you see when logged in.
 
If you are logged in and did not click on it yet you can almost certainly just find it by id:
Code:
id="placeholder-area"
 
If you are logged in and did not click on it yet you can almost certainly just find it by id:
Code:
id="placeholder-area"
might have some trouble with this as that element is hidden when logged in. The simplest option I think is to find it using the aria-label, maybe something like
Code:
By.XPath("//div[@aria-label='Add a comment...']")
 
when you are trying to find this box using selenium have you logged in? The box rendered when you are not logged in is different from what you see when logged in.
If you are logged in and did not click on it yet you can almost certainly just find it by id:
Code:
id="placeholder-area"
might have some trouble with this as that element is hidden when logged in. The simplest option I think is to find it using the aria-label, maybe something like
Code:
By.XPath("//div[@aria-label='Add a comment...']")
JavaScript:
$x('//div[@id="contenteditable-root"]')[0]

View attachment 205561
I fixed it guys, sorry I didn't mention it I was so busy. The problem was that once you click the comment text box element it disappeas and you need to find another element once the first element is clicked. Thanks everyone for trying to help I really appreaciate it. Wish you good luck with your journeys
 
public const string Avatar = "div[id='channel-header-container'] yt-img-shadow[id='avatar']>img";
public const string UserName = "div[id='channel-header-container'] yt-formatted-string[id='text']";
public const string Subscribers = "div[id='channel-header-container'] yt-formatted-string[id='subscriber-count']";
public const string Desc = "yt-formatted-string[id='description']";
public const string Detail = "div[id='details-container']";
public const string Country = "div[id='details-container']>table tr:last-child>td[class='style-scope ytd-channel-about-metadata-renderer']>yt-formatted-string";
public const string Link = "div[id='link-list-container']";
 
Back
Top