Python Forum
Click in the (…) icon in youtube with selenium PyChrome
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Click in the (…) icon in youtube with selenium PyChrome
#1
Hello, I'm trying to do a bot that sign in youtube, pick a random video and click in the (...) button, I have done the SIGN IN and the video pick but I couldn't be able to click the button (...) inside the video. I have tried by ID, class name, xpath and css locator. I'm using python selenium PyChrome for this, thanks for your answers :)
Using this on python:
link = "youtube.com"
from pyChrome import PyChrome
browser = PyChrome()
browser.open(link)
#here goes the code for the SIGN IN and the video pick up, let's imagine that we have already picked one video
locator = ""
element = browser.findElement(id,classname,xpath,css = locator) #have tried those attributes
browser.clickElement(element)

By clicking in the inspect option of the button (...):
<button is="paper-icon-button-light" id="button" class="dropdown-trigger style-scope ytd-menu-renderer" aria-label="More actions">
<yt-icon class="style-scope ytd-menu-renderer"><svg viewBox="0 0 24 24" preserveAspectRatio="xMidYMid meet" focusable="false" class="style-scope yt-icon" style="pointer-events: none; display: block; width: 100%; height: 100%;"><g class="style-scope yt-icon">
<circle cx="5" cy="12" r="2" class="style-scope yt-icon"></circle><circle cx="12" cy="12" r="2" class="style-scope yt-icon"></circle><circle cx="19" cy="12" r="2" class="style-scope yt-icon"></circle>
</g></svg>

</yt-icon>
<paper-ripple class="style-scope paper-icon-button-light circle">


<div id="background" class="style-scope paper-ripple" style="opacity: 0;"></div>
<div id="waves" class="style-scope paper-ripple"></div>
</paper-ripple></button>

The error message it's always: Couldn't find element or Couldn't click element by id,classname,css or Xpath
Reply
#2
Ive never used pychrome, but have you tried it with just selenium and the default Chrome? Might as well be worth a test to see if this PyChrome has some issues.

What is the actual xpath you are using...i get
//*[@id="button"]/yt-icon

9/10 times i cant find an element; i forgot to delay as the program tripped over itself. Try to add a delay after logging in, as well as picking a video
Recommended Tutorials:
Reply
#3
(Oct-17-2017, 07:18 PM)metulburr Wrote: Ive never used pychrome, but have you tried it with just selenium and the default Chrome? Might as well be worth a test to see if this PyChrome has some issues.

What is the actual xpath you are using...i get
//*[@id="button"]/yt-icon

9/10 times i cant find an element; i forgot to delay as the program tripped over itself. Try to add a delay after logging in, as well as picking a video

Hello metulburr, thanks for the reply and I have already used that xpath and it goes to the "upload a video" button, it seems that they have the same xpath at that point and it is taking it first. I'm wondering if there is a chance to use the arial-label attribute, I have been looking for it but I couldn't find anything about it.
Reply
#4
Can try this xPath.
//button[@aria-label="More actions"]
Reply
#5
(Oct-17-2017, 10:37 PM)snippsat Wrote: Can try this xPath.
//button[@aria-label="More actions"]

This was the answer, Thank you!!!
Reply
#6
(Oct-17-2017, 10:37 PM)snippsat Wrote: Can try this xPath.
//button[@aria-label="More actions"]

How did you find that via inspection?
Recommended Tutorials:
Reply
#7
Have to do it another way when inspection copy fails.
<button is="paper-icon-button-light" id="button" class="dropdown-trigger style-scope ytd-menu-renderer" aria-label="More actions">
aria-label is an attribute that can be selected with @(Selects attributes).
So as example the CSS class attribute would be:
//button[@class="dropdown-trigger style-scope ytd-menu-renderer"]
But as several buttons that has same name of class and id,there is aria-label="More actions" attribute that is unique to only that button.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Click on a button on web page using Selenium Pavel_47 7 4,681 Jan-05-2023, 04:20 AM
Last Post: ellapurnellrt
  Log In Button Won't Click - Python Selenium Webdriver samlee916 2 3,827 Jun-07-2020, 04:42 PM
Last Post: samlee916
  Hyperlink Click is not working in Selenium webdriver rajeev1729 0 2,025 May-02-2020, 11:21 AM
Last Post: rajeev1729
  selenium click in iframe fails 3Pinter 6 5,116 Apr-29-2020, 12:59 PM
Last Post: Larz60+
  Python Selenium .click() Loads Error - Works Manually.- Events not Triggered NSearch 24 11,755 Aug-14-2019, 02:23 PM
Last Post: NSearch
  Selenium click on popup button??? GuJu 7 7,868 Jul-20-2019, 09:21 AM
Last Post: Nizam
  Click Element if displayed using Selenium and Python giaco__mar 1 3,538 Dec-27-2018, 06:19 PM
Last Post: metulburr
  Click an icon on a browser cheeks13 2 3,420 Aug-09-2018, 01:14 PM
Last Post: cheeks13
  Selenium xpath finding gif to click fyec 1 3,805 Jul-27-2018, 05:20 PM
Last Post: snippsat
  Selenium chromedriver and click action Gilles95 4 13,278 Feb-07-2018, 07:28 PM
Last Post: Gilles95

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020