Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 666
Magnus Jensen Avatar asked Sep 12 '26 05:09

Magnus Jensen


1 Answers

You can use it in XPath selector as below:

//input[@data-aft="fodselsnummer"]
like image 179
Andersson Avatar answered Sep 15 '26 09:09

Andersson