Get all element attributes using protractor

后端 未结 4 763
故里飘歌
故里飘歌 2020-12-17 15:54

According to the documentation, to get a single attribute by name you can use .getAttribute() on a WebElement:

var myElement = element(by.id(\'m         


        
4条回答
  •  天命终不由人
    2020-12-17 16:10

    You can expand javascript's Element type and add getAttributes() function:

    Element.prototype.getAttributes = function() {
        return (function (node) {
            var attrs = {};
            for (var i=0;i

    demo

    then you can test integrity of attributes using the same method you use for one attribute:

    var myElement = element(by.id('myId'));
    expect(myElement.getAttributes()).toEqual({'attr1': 'value1', 'attr1': 'value1', ... });
    

提交回复
热议问题