Problem Selenium (python) unable to locate element

advertisements

I am trying to click in a button of a website that is in a dropdown menu. I've tried different approach (xpath, element, link text.. ) but no one of these works and I am getting as error "unable to locate element"

The html code of the button is:

<a class="yuimenuitemlabel" href="javascript:exportToCSV()"> <span class="menu-text">Export All: CSV</span> </a> </li>

I tried the below approaches without luck:

browser.find_element_by_xpath("//*[@id='csv-export-item']/a/span").click()

browser.find_element_by_link_text('Export All: CSV')

browser.find_element_by_css_selector('span.content').click()

Any idea what could I do here? Thanks a lot.


Try this xpath once

//span[contains(text(),'Export All: CSV')]

Thank You, Murali