0

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.

Rafayet Ullah
  • 1,108
  • 4
  • 14
  • 27
Gonzalo
  • 1,084
  • 4
  • 20
  • 40
  • have you tried evaluating your xpath alone on browser console? – Radan May 10 '16 at 09:31
  • We will need a link or a bigger chunk of html code. The problem can also be that the code you're trying to get is javascript generated and you need to Explicitly wait for the element to appear before you fetch it – Rafael Almeida May 10 '16 at 09:34
  • Obrigado Rafael. I also thought that .. used time.sleep(5) to avoid such issue. – Gonzalo May 10 '16 at 09:42

2 Answers2

0

Try this xpath once

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

Thank You, Murali

murali selenium
  • 3,847
  • 2
  • 11
  • 20
  • @Gonzalo, at least it was found :) Try `implicit/explicit` wait for page complete rendering – Andersson May 10 '16 at 09:50
  • ok. I will need to research on how implicit/explicit works. thank you. – Gonzalo May 10 '16 at 09:58
  • @Gonzalo i hope you cross checked element is inside any frame/iframe or not. if element is inside – murali selenium May 10 '16 at 10:51
  • @muraliseleniumtrainer I am not an HTML expert but i think that's exactly the issue. I can see a few iframes codes in the code. Any idea how could I achieve that..? – Gonzalo May 10 '16 at 10:57
  • Inspect your element in firebug. After just scroll up slowly watching parent and its parent of your element. if any parent contains – murali selenium May 10 '16 at 11:05
0

Try with the following xpath method call once

browser.find_element_by_xpath("//*[text()='Export All: CSV']")

Hope it helps.

Strik3r
  • 1,052
  • 8
  • 15