Search code examples
seleniumtagsautomated-tests

Using data tags for automated selenium tests


The developers on my team have implemented some tags to support capybara and automated tests. I want to use the same tags for Selenium Webriver. The element I want to locate is typically defined as follows:

<label for="manntallsSok:manntallsSokForm:tabView:ssn">Fødselsnummer</label>
<input id="manntallsSok:manntallsSokForm:tabView:ssn" class="ui- inputfield ui-inputmask ui-widget ui-state-default ui-corner-all  form-control focusable"
type="text" aria-required="true" data-aft="fodselsnummer"  name="manntallsSok:manntallsSokForm:tabView:ssn" role="textbox"  aria-disabled="false"
aria-readonly="false">

The hooks the developers hava made is typicaly:

data-aft="fodselsnummer"

Is it possible to use this hook/tag in a selenium locateElement?


Solution

  • You can use it in XPath selector as below:

    //input[@data-aft="fodselsnummer"]