How to compare element width and height with getSize () function with Protractor test?

Good morning, dear colleagues. I have a question about selenium methods. In my case, I am testing an angular application using a protractor, and I want to compare the return value from a function getSizewith the set values ​​in my test. Here is the code below -
var searchForm = element(by.id('search'));

 it('searchForm must have width: 400px and height: 400px', function(){
  //expect(browser.driver.manager().window().getSize()).toEqual(400, 400);
  searchForm.getSize();
  searchForm.width.toEqual(400);
  searchForm.height.toEqual(400);

});

please help me solve the problem. I hope you help me.

+4
source share
2 answers

"" getSize() , width, height, hcode and class . , , . -

 it('searchForm must have width: 400px and height: 400px', function(){
    var searchForm = element(by.id('search'));
    searchForm.getSize().then(function(eleSize){
        console.log('element size: '+eleSize); //eleSize is the element size object
        expect(eleSize.width).toEqual(400);
        expect(eleSize.height).toEqual(400);
    });
});

- spec it . , .

+9

:

var elemHeight = element.getAttribute('height')

,

elemHeight.then(function (height) {...

expect(elemHeight).toEqual(400);

0

Source: https://habr.com/ru/post/1610377/


All Articles