Hi,
I want to collect data from YouTube channesls. But I fail to accept cookies from YouTube. I suppose it has something to do with this shadow-dom magic or my lack of competence with those crazy locator strategies from playwright. I already spent two evenings without any luck, maybe one of you know how to solve it.
This is the task:
*** Settings ***
Library RPA.Browser.Playwright
*** Keywords ***
Open YouTube Channel
[Arguments] ${channel}
New Browser headless=False
New Page https://www.youtube.com/channel/${channel}/featured
Click on videos panel
Click xpath=//div[@id="tabsContent"]/paper-tab[2]
Click on first video
Click xpath=//ytd-two-column-browse-results-renderer//div[@id="contents"]//div[@id="items"]//ytd-thumbnail
Anticipate SignIn PopUp
Sleep 10s
${page_contains_sign_in} Get Element Count xpath=//ytd-popup-container/paper-dialog then ${True} if value else ${False}
Run Keyword If ${page_contains_sign_in} Click xpath=//div[@id="dismiss-button"]
Anticipate Cookie PopUp
Sleep 5s
${agree_to_cookies} Get Element Count [id=introAgreeButton] then ${True} if value else ${False}
#Run Keyword If ${agree_to_cookies}
Click [id=introAgreeButton]
*** Tasks ***
Click Picture
Open YouTube Channel UCmdUNLWfRA2MvXlN9c5vtNA
Click on videos panel
Click on first video
Anticipate SignIn PopUp
Anticipate Cookie PopUp # this is where I cannot find the "I agree" button
While somehow the SignIn Popup is no problem (although i wonder why my randomly build locator works), I fail to click on I Agree in the Cookie PopUp .
Regards,
Markus