I am trying to verify that there is a button on the page named Select. The Select button has a dynamic span id.

This is what firebug is showing me:

span id="dijit_form_Button_18" class="dijitReset dijitStretch dijitButtonContents" data-dojo-attach-point="titleNode,focusNode" role="button" aria-labelledby="dijit_form_Button_18_label" tabindex="0" aria-disabled="false" style="-moz-user-select: none;"

Here is my code:

  • What problem are you running into? Are you facing any error? – the_coder Feb 23 '17 at 4:00
  • @the_coder null is returned – JJ Whispers Feb 23 '17 at 4:14
  • You mean nullpointer exception? if so please mention the error in the question. – the_coder Feb 23 '17 at 4:22
  • What about using: //button[@name='Select']/span? It should do the same? Also check case sensitivity. Is there difference between 'Select' and 'select'? – sanastasiadis Feb 23 '17 at 11:13
  • Im trying to retrieve the attribute of a dynamic ID – JJ Whispers Feb 23 '17 at 13:45

If there is no good Xpath or CSS Selector solution, the method that always works is some visual check with Sikuli or Kantu.

SikuliX automates anything you see on the screen of your desktop computer running Windows, Mac or some Linux/Unix. It uses image recognition powered by OpenCV to identify and control GUI components. This is handy in cases when there is no easy access to a GUI's internals or the source code of the application or web page you want to act on. It can be combined with Selenium.

Not the answer you're looking for? Browse other questions tagged or ask your own question.