1

So I am currently trying to scrape data from youtube pages. I am using Selenium in order to do this automatically. The issue is that the browser that comes up has not signed in as I am on the non generated selenium browser. So it comes up with the sign in or 'No Thanks' icon. I have looked around and found the Xpath for the 'No Thanks' button but my system indicates 'element not interactable'.

Xpath of the button: enter image description here

Code I inputted:

enter image description here

#We need to tell the drive to find the video of choice
driver.find_element_by_xpath('//*[@id="video-title"]')
driver.find_element_by_xpath('//*[@id="button"]')

#Interact with the above
driver.find_element_by_xpath('//*[@id="video-title"]').click()
driver.find_element_by_xpath('//*[@id="button"]').click()

I tried to copy the full Xpath also. Any suggestions?

5
  • Check whether the button is located within an iframe. Commented Oct 31, 2020 at 10:36
  • I just checked, this pop-up does not. But there one that follows it does. Commented Oct 31, 2020 at 11:17
  • Isn't the button within the iframe? Are u sure? Commented Oct 31, 2020 at 11:43
  • Yes very sure. This is it <paper-dialog role="dialog" tabindex="-1" class="style-scope ytd-popup-container" prevent-autonav="true" style="outline: none; z-index: 2202; position: fixed; top: 0px; left: 718.219px; box-sizing: border-box; max-height: 376px; max-width: 1992px;"><!--css-build:shady--> Commented Oct 31, 2020 at 12:14
  • So I just checked, its an overlay. But I read around if you can't interact with it then it is in an iframe. But it does not seem to be in an iframe. Though there is an iframe wrapper above the overlay object but not its parent. Any suggestions? Commented Nov 1, 2020 at 4:43

1 Answer 1

1

So, after nearly a whole day, I came up with a simple fix.

Could not quite find the xpath or id or name of the pop-up. But if I reload the page, it does not show up again.

So a simple

driver.refresh()

or

driver.get(driver.current_url)

should work after you click on your link.

Issue - another iframe object pops up, the google cookies. I tried deleting all cookies but it still loads. I also tried other ways of getting into the iframe and then clicking on the button to no avail. But the link below helped with this (the second answer):

Youtube google popup - selenium

Thanks!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.