1

I am using protractor to write my tests and when I search the attribute of an element it works except with "data-" attributes:

ptor.findElement(protractor.By.css('.wrap.loaded'))
                .then(function(thumb) {
                    thumb.getAttribute('data-width')
                        .then(function(w) {
                      ... //*w == null*
                });
});

As I said, if I have a non data attribute, it works fine:

ptor.findElement(protractor.By.css('.wrap.loaded'))
                .then(function(thumb) {
                    thumb.getAttribute('class')
                        .then(function(c) {
                      ... //*c == wrap loaded*
                });
});

Does anyone know why it happens and if there is a way to get the data attributes from a Wedriver.WebElement in javascript? Thanks.

Jenninha
  • 1,357
  • 2
  • 20
  • 42
  • Just for the purpose of debugging, [get all element's attributes](http://stackoverflow.com/questions/27694570/get-all-element-attributes-using-protractor) and post what are you getting. Thanks. – alecxe Jan 07 '15 at 16:10
  • Unrelated to your issue but as a good practice, stop using `ptor.findElement`. Instead use: `$('.wrap.loaded').getAttribute('class').then(function(c) {//do something with c});` – hankduan Jan 07 '15 at 19:16
  • Do you mean using JQuery on my tests? – Jenninha Jan 08 '15 at 22:06

0 Answers0