Protractor stale element reference when using the each() method

前端 未结 4 453
一向
一向 2021-01-14 15:24

I am getting the error below as a result of using the each() method in protractor. It has worked fine in the past but is now consistently failing with this error.

4条回答
  •  抹茶落季
    2021-01-14 16:07

    In a nutshell, it happens because each() just fires commands simultaneously against all elements. In your case you probably need to go this way element.all(bars).getCssValue('width')).then(array => {/*do what you want with returned array here*/})

    * Edited *

    What you want to do is

    element.all(bars).getCssValue('width')).then(array => {
        // tests is at least one element will not be "0px"
        let elementHasWidth = array.some(elem => elem !== "0px");
        expect(elementHasWidth).toBe(true);
    })
    

提交回复
热议问题