Python Forum

Full Version: Click dropdown menu option with Selenium PyChrome
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello! I'm trying to click on the button of "Suicide or self injury" inside the report menu of youtube. I have already clicked on the "Harmful dangerous acts" and open up the dropdown menu of "Choose one" but when I try to click the "Suicide or self injury" it gives me the error of ERROR:root:ElementNotVisibleException: Couldn't Click on this element.

I'm using selenium python PyChrome webdriver and the last part of my code is:

#open the "choose one" drop-menu
locator = "#options > paper-dropdown-menu:nth-child(11)" 
element = browser.findElement(css = locator)
browser.clickElement(element)
time.sleep(2)
#trying to choose the "Suicide or self injury" option
locator = "//*[@id='contentWrapper']/div/paper-listbox/paper-item[4]"
element = browser.findElement(xpath = locator)
browser.clickElement(element)
try this xpath
//*[@id="contentWrapper"]/div/paper-listbox/paper-item[4]/yt-formatted-string
or CSS selector
#contentWrapper > div > paper-listbox > paper-item:nth-child(4) > yt-formatted-string
(Oct-26-2017, 09:35 PM)metulburr Wrote: [ -> ]try this xpath
//*[@id="contentWrapper"]/div/paper-listbox/paper-item[4]/yt-formatted-string
or CSS selector
#contentWrapper > div > paper-listbox > paper-item:nth-child(4) > yt-formatted-string

No, it keeps showing the ERROR:root:ElementNotVisibleException: Couldn't Click on this element. error Confused
Do you have an example code snippet that gets to that point of error? Im too lazy to make my own at this point.