describe('Удаление товара:',function(){
it('Гость', function () {
let testResult = true;
return this.browser .reload()
.url('/')
.localStorage('POST',{key: 'subscribe-modal-visibled', value: 'true'})
.localStorage('POST',{key: 'geo-popup', value: '{"isDetected":true}'})
.localStorage('POST',{key: 'geo-link', value: '{"isDetected":true}'})
.refresh()
.waitForVisible('.envelopeIcon_3E', 10000)
.then(() => assert.isTrue(true), (err)=> {console.log(err)})
.click('.icon_menu')
.then(() => assert.isTrue(true), (err)=> {console.log(err); testResult = false})
.waitForVisible('.main-menu__body>.nav>.nav__container>.nav-item:nth-child(7)>.nav-item__container>.icon_material')
.then(() => assert.isTrue(true), (err)=> {console.log(err); testResult = false})
.scroll('.main-menu__body>.nav>.nav__container>.nav-item:nth-child(7)>.nav-item__container svg')
.click('.main-menu__body>.nav>.nav__container>.nav-item:nth-child(7)>.nav-item__container svg')
.then(() => assert.isTrue(true), (err)=> {console.log(err); testResult = false})
.waitForVisible('.nav-item_subnav:nth-child(7) .nav-item__subnav .nav__container .nav-item:nth-child(1)', 3000)
.then(() => assert.isTrue(true), (err)=> {console.log(err); testResult = false})
.click('.nav-item_subnav:nth-child(7) .nav-item__subnav .nav__container .nav-item:nth-child(1)')
.then(() => assert.isTrue(true), (err)=> {console.log(err); testResult = false})
.waitForVisible('.recomms__head', 10000)
.then(() => assert.isTrue(true), (err)=> {console.log(err)})
.waitForVisible('.products__items', 6000)
.then(() => assert.isTrue(true), (err)=> {console.log(err); testResult = false})
.click('.products__items .product:nth-child(1) .product__cart button')
.then(() => assert.isTrue(true), (err)=> {console.log(err); testResult = false})
.click('.products__items .product:nth-child(2) .product__cart button')
.then(() => assert.isTrue(true), (err)=> {console.log(err); testResult = false})
.click('.products__items .product:nth-child(3) .product__cart button')
.then(() => assert.isTrue(true), (err)=> {console.log(err); testResult = false})
.click('.products__items .product:nth-child(4) .product__cart button')
.then(() => assert.isTrue(true), (err)=> {console.log(err); testResult = false})
.waitForVisible('.cart-button__popup', 3000)
.then(() => assert.isTrue(true), (err)=> {console.log(err); testResult = false})
.getText('.cart-menu__counter')
.then(text => assert.isTrue(text === '4','False: ' + text + '!= 4'),(err)=> {console.log(err); testResult = false})
.click('.icon_shop_cart')
.then(() => assert.isTrue(true), (err)=> {console.log(err); testResult = false})
.waitForVisible('.cart-item', 5000)
.then(() => assert.isTrue(true), (err)=> {console.log(err); testResult = false})
.elements('.cart-item')
.then(result => assert.isTrue(result.value.length === 4, 'False: ' +result.value.length + '= .cart-item != 4'), (err)=> {console.log(err); testResult = false})
.getValue('.cart__items .cart-item:nth-child(1) .cart-item__quantity .input__control')
.then(value => assert.isTrue(value == 1, 'False: ' + value + ' =.cart__items .cart-item:nth-child(1) .cart-item__quantity .input__control != 1'),(err)=> {console.log(err); testResult = false})
.doubleClick('.cart__items .cart-item:nth-child(1) .cart-item__quantity .input__control')
.then(() => assert.isTrue(true), (err)=> {console.log(err); testResult = false})
.keys('0')
.then(() => assert.isTrue(true), (err)=> {console.log(err); testResult = false})
.waitForExist('.cart-item_deleted', 3000)
.then(() => assert.isTrue(true), (err)=> {console.log(err); testResult = false})
.waitForVisible('.cart-item_locked', 2000, true)
.then(() => assert.isTrue(true), (err)=> {console.log(err); testResult = false})
.elements('.cart-item:not(.cart-item_deleted)') // not deleted positions (those, that remained) .then(result => assert.isTrue(result.value.length == 3, 'False: ' +result.value.length + '= .cart-item != 4'), (err)=> {console.log(err); testResult = false})
.elements('.cart-item')
.then(result => assert.isTrue(result.value.length == 4, 'False: ' +result.value.length + '= .cart-item != 4'), (err)=> {console.log(err); testResult = false})
.isVisible('.cart__items .cart-item:nth-child(1) .cart-item__image')
.then(result => assert.isFalse(result, 'Картинка удаленного товара видна'), (err)=> {console.log(err); testResult = false})
.getText('.cart-item:nth-child(1) .cart-item__deleted .cart-item__text')
.then(text => assert.isTrue(text === 'Товар убран из корзины', 'Текст не соответствует "Товар убран из корзины"'), (err)=> {console.log(err); testResult = false})
.getText('.cart-item:nth-child(1) .cart-item__deleted .button__text')
.then(text => assert.isTrue(text === 'Вернуть','Текст не соответствует "Вернуть"'), (err)=> {console.log(err); testResult = false})
.isVisible('.cart__items .cart-item:nth-child(1) .cart-item__title')
.then(result => assert.isTrue(result,'Название товара не видно'), (err)=> {console.log(err); testResult = false})
.isVisible('.cart__items .cart-item:nth-child(1) .cart-item__packing-info')
.then(result => assert.isFalse(result,'Информация о цене и фасовке видна'), (err)=> {console.log(err); testResult = false})
.isVisible('.cart__items .cart-item:nth-child(1) .cart-item__actions')
.then(result => assert.isFalse(result,'Кнопка "Убрать из корзины" видна'),(err)=> {console.log(err); testResult = false})
.getValue('.cart__items .cart-item:nth-child(2) .cart-item__quantity .input__control')
.then(value => assert.isTrue(value == 1,'Начальное значение количества товара2 не равно 1'), (err)=> {console.log(err); testResult = false})
.click('.cart__items .cart-item:nth-child(3) .cart-item__actions .button')
.then(() => assert.isTrue(true), (err)=> {console.log(err); testResult = false})
.pause(500)
.waitForVisible('.cart-item_locked', 1000, true)
.then(() => assert.isTrue(true), (err)=> {console.log(err); testResult = false})
.elements('.cart-item:not(.cart-item_deleted)')
.then(result => assert.isTrue(result.value.length == 2, 'Количество неудаленных товаров не равно 2'), (err)=> {console.log(err); testResult = false})
.elements('.cart-item')
.then(result => assert.isTrue(result.value.length == 4, 'Количество всех товаров не равно 4'), (err)=> {console.log(err); testResult = false})
.isVisible('.cart__items .cart-item:nth-child(3) .cart-item__image')
.then(result => assert.isFalse(result, 'Картинка удаленного товара видна'), (err)=> {console.log(err); testResult = false})
.getText('.cart-item:nth-child(3) .cart-item__deleted .cart-item__text')
.then(text => assert.isTrue(text === 'Товар убран из корзины','Текст не соответствует "Товар убран из корзины"'),(err)=> {console.log(err); testResult = false})
.getText('.cart-item:nth-child(3) .cart-item__deleted .button__text')
.then(text => assert.isTrue(text === 'Вернуть','Текст не соответствует "Вернуть"'), (err)=> {console.log(err); testResult = false})
.isVisible('.cart__items .cart-item:nth-child(3) .cart-item__title')
.then(result => assert.isTrue(result,'Название товара не видно'), (err)=> {console.log(err); testResult = false})
.isVisible('.cart__items .cart-item:nth-child(3) .cart-item__packing-info')
.then(result => assert.isFalse(result,'Информация о цене и фасовке видна'), (err)=> {console.log(err); testResult = false})
.isVisible('.cart__items .cart-item:nth-child(3) .cart-item__actions')
.then(result => assert.isFalse(result,'Кнопка "Убрать из корзины" видна'), (err)=> {console.log(err); testResult = false})
.click('.cart-item:nth-child(1) .cart-item__deleted .button__text') // кнопка вернуть .then(() => assert.isTrue(true), (err)=> {console.log(err); testResult = false})
.waitForVisible('.cart-item:nth-child(1) .icon_delete_forever')
.then(() => assert.isTrue(true), (err)=> {console.log(err); testResult = false})
.scroll('.cart-item:nth-child(3)')
.click('.cart-item:nth-child(3) .cart-item__deleted .button__text')
.then(() => assert.isTrue(true),(err)=> {console.log(err); testResult = false})
.waitForVisible('.cart-item:nth-child(3) .icon_delete_forever')
.then(() => assert.isTrue(true),(err)=> {console.log(err); testResult = false})
.then(()=> assert.isTrue(testResult))
});

Вот в этом участке была трабла. Почему-то вместо третьего элемента клик получала шапка.
Оно немного прыгало и клик получал другой элемент.
Когда мы прописали такой вариант:
.scroll('.cart-item:nth-child(3) .cart-item__deleted .button__text')
.click('.cart-item:nth-child(3) .cart-item__deleted .button__text')
Он не сработал, надо было только .cart-item:nth-child(3)
Т.е. вот так:
.scroll('.cart-item:nth-child(3)')
Потому что когда мы обращаемся конкретно к кнопке, она находится внизу, а надо ко всему блоку, к большому элементу в целом.

Комментариев нет:
Отправить комментарий