javascript 性感日期桌面测试用例无头模式全部通过

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript 性感日期桌面测试用例无头模式全部通过相关的知识,希望对你有一定的参考价值。

// Final Version

// import { page, browser } from "../global"

require('dotenv').config()

const { exists } = require('../jest/utils')
const faker = require('faker');
const fs = require('fs');
const path = require('path');

// test("Setup", async() => {
//   await page.setRequestInterception(true)
//   page.on('request', (request) => {
//       (['image','font'].indexOf(request.resourceType()) !== -1 ) ? request.abort() : request.continue()
//   })
// })

const fakeEmail = faker.internet.email();
const itomail = faker.name.firstName() + '@itobuz.com';
const first_name = faker.name.firstName() + 'abc';
const pass = faker.internet.password();
const message = faker.lorem.sentence();
const paras = faker.lorem.paragraphs();

// LANDING PAGE

describe("Landing Page", async() => {
  describe("Registration Error Checks", async() => {
    it("Registration Without Email Id", async() => {
      await page.goto(baseUrl, {waitUntil: "networkidle0"})
      await page.click('#register-form form button')
      await page.waitForSelector('app-register-step-one p-autocomplete + div.msg--error')
    })
    it("Registration With Incorrect Email Id", async() => {
      await page.reload({waitUntil: "networkidle0"})
      await page.waitForSelector('form input')
      await page.type('form input', 'testing123@bichuwah.co.in')
      await page.click('#register-form form button')
      await page.waitForSelector('app-register-step-one p-autocomplete + div.msg.msg--error')
    })
  })

  describe("Email Id Domain Names Auto Complete", async() => {
    it("Email Id Domain Names Auto Complete", async() => {
      await page.reload({waitUntil: "networkidle0"})
      await page.type('form input', 'rajdeep@o')
      await page.waitForSelector('form > div > div:nth-child(2) > div > p-autocomplete > span > div > ul')
    })
  })

  describe("Email-field autofocus", async() => {
    it("Click on 'Urnime Gratis' button (Find members section) focuses email field", async() => {
      await page.reload({waitUntil: "networkidle0"})
      await page.click('div.find-members a')
      await page.keyboard.type('test')
      const inputVal = await page.$eval('app-register-step-one form input', e => e.value)
      expect(inputVal).toBe('test')
    })
    it("Click 'Urnime Gratis' left text (Casual Meet section) focuses email field", async() => {
      await page.reload({waitUntil: "networkidle0"})
      await page.click('div.casual-meet div.column:nth-child(1) a')
      await page.keyboard.type('123')
      const inputVal = await page.$eval('app-register-step-one form input', e => e.value)
      expect(inputVal).toBe('123')
    })
    it("Click 'Urnime Gratis' right text (Casual Meet section) focuses email field", async() => {
      await page.reload({waitUntil: "networkidle0"})
      expect.assertions(2)
      await page.click('div.casual-meet div.column:nth-child(2) a')
      await page.keyboard.type('xyz')
      const inputVal = await page.$eval('app-register-step-one form input', e => e.value)
      expect(inputVal).toBe('xyz')
      await page.reload({waitUntil: "networkidle0"})
      const inputValReset = await page.$eval('app-register-step-one form input', e => e.value)
      expect(inputValReset).toBeFalsy()
    })
  })

  describe("Registration process step by step", async() => {
    it("first step", async() => {
      await page.goto(baseUrl, {waitUntil: "networkidle2"})
      await page.waitForSelector('input[type="email"]')
      await page.type('input[type="email"]', itomail)
      await page.selectRandom('div.register select')
      await page.click('form button')
      await page.waitForSelector('div.custom-modal.register')
    })
    it("second step", async() => {
        await page.type('input[formControlName="nick_name"]', first_name)
        await page.type('input[formControlName="name"]', first_name)
        await page.type('input[formControlName="password"]', pass)
        await page.selectRandom('div.custom-modal.register select')
        await page.click('ngb-modal-window app-register-step-two div.form-wrap > form > div.button-wrap > button')
    })
    it("third step", async() => {
        await page.waitForSelector('div.register-step-three-container')
        // let selectBoxesSelectors = [
        //   'div.register-step-three-container select[formcontrolname="country_id"]',
        //   'div.register-step-three-container select[formcontrolname="province_id"]',
        //   'div.register-step-three-container select[formcontrolname="height"]',
        //   'div.register-step-three-container select[formcontrolname="weight"]',
        //   'div.register-step-three-container select[formcontrolname="body_type_id"]',
        //   'div.register-step-three-container select[formcontrolname="hair_color_id"]',
        //   'div.register-step-three-container select[formcontrolname="eye_color_id"]'
        // ]
        // await page.selectRandom(selectBoxesSelectors, { multiple: true })
        // await page.type('div.register-step-three-container textarea[formcontrolname="description"]', message)
        await page.waitForSelector('.btn-green')
        await page.click('.btn-green')
    })
    it("Check that it has the correct email", async() => {
      await page.waitForSelector('ngb-modal-window app-register-confirm > div > div > div.register')
      await page.waitForSelector('div.register .img-wrapper img.tick')
      let email1 = await page.$eval('div.register div.email-confirmation span.bold-text', e => e.innerText)
      let email2 = await page.$eval('div.register input[formcontrolname="email"]', e => e.value ) 
      expect(email1).toBe(email2)
      expect(email1).toBe(itomail)
    })
    it("Resends email", async () => {
      await page.click('div.register button.resend-email')
      await page.waitForSelector('div.register div.msg--success')
    })
  })
})

// LOGIN PAGE

describe("Login Page", async() => {
  describe("Forgot Password", async() => {
    describe("Form Error Checks", async() => {
      it("Submit without email Id", async() => {
        await page.goto(baseUrl, {waitUntil: "networkidle0"})
        await page.click('.login-btn')
        await page.waitForSelector('app-login form > div > a')
        await page.click('app-login form > div > a')
        await page.waitForSelector('ngb-modal-window form button')
        await page.click('ngb-modal-window form button')
        await page.waitForSelector('ngb-modal-window form > div.msg.msg--error')
      })
      it("Submit with incorrect email id", async() => {
        await page.type('ngb-modal-window form > input', 'rajib@xyzs.co.qwerty')
        await page.click('ngb-modal-window form button')
        await page.waitForSelector('ngb-modal-window form > div.msg.msg--error')
      })
    })

    describe("Form Success check", async() => {
      it("Submit with valid email", async() => {
        await page.$eval('ngb-modal-window form > input', el => el.value = '')
        await page.type('ngb-modal-window form > input', process.env.USERNAME_FORGOTPASSWORD)
        await page.click('ngb-modal-window form button')
      })
      it("Success Message appears on sending valid form", async() => {
        await page.waitForSelector('ngb-modal-window form > div.msg.msg--success')
      })
    })

    describe("Modal closes on X button", async() => {
      it("Modal closes on X button", async() => {
        await page.click('ngb-modal-window div.heading-wrap > button')
        try {
          await page.waitForSelector('ngb-modal-window', {timeout: 1000})
        }
        catch(err) {
          console.log('Modal Not Found Hence Test Passed')
        }
      })
    })
  })

  describe("Login Cases", async() => {
    describe("Login Error checks", async() => {
      it("unregistered user login", async() => {
        await page.waitForSelector('.login-details > form')
        await page.$eval('input[formcontrolname="email_or_nick"]', el => el.value = '')
        await page.type('input[formcontrolname="email_or_nick"]', itomail)
        await page.type('input[formcontrolname="password"]', pass)
        await page.click('button[type="submit"]')
        await page.waitForSelector('form button[type="submit"]+div.msg--error')
      })
      it("login without any user credentials", async() => {
        await page.reload({waitUntil: "networkidle0"})
        await page.$$eval('app-login form > input.sd-control', e => e.length === 2, {polling: 'mutation'})
        await page.waitForSelector('app-login form > button[type="submit"]')
        await page.click('app-login form > button[type="submit"]')
        await page.waitForSelector('input[formcontrolname="email_or_nick"]+div.msg--error')
        await page.waitForSelector('input[formcontrolname="password"]+div.msg--error')
      })
      it("wrong credential user login", async() => {
        await page.reload({waitUntil: "networkidle0"})
        await page.type('input[formcontrolname="email_or_nick"]', fakeEmail)
        await page.type('input[formcontrolname="password"]', pass)
        await page.click('button[type="submit"]')
        await page.waitForSelector('form button[type="submit"]+div.msg--error')
      })
      it("entering only email displays 'enter password'", async() => {
        await page.reload({waitUntil: "networkidle0"})
        await page.type('input[formcontrolname="email_or_nick"]', fakeEmail)
        await page.click('button[type="submit"]')
        await page.waitForSelector('input[formcontrolname="password"]+div.msg--error')
      })
      it("focusing in and out of the email field", async() => {
        await page.reload({waitUntil: "networkidle0"})
        await page.waitForSelector('app-login div > form')
        await page.type('input[formcontrolname="email_or_nick"]', '')
        await page.click('div.search-result-header h3')
        await page.waitForSelector('div.msg--error')
      })
      it("focusing in and out of the password field", async() => {
        await page.reload({waitUntil: "networkidle0"})
        await page.waitForSelector('input[formcontrolname="password"]')
        await page.click('input[formcontrolname="password"]')
        await page.click('input[formcontrolname="email_or_nick"]')
        await page.click('div.search-result-header h3')
        await page.waitForSelector('input[formcontrolname="password"]+div.msg--error')
      })
    })

    describe("Successful Login Cases", async() => {
      describe.skip("First time registered-user login", async() => {
        it("Logged in", async() => {
          await page.reload({waitUntil: "networkidle0"})
          await page.waitForSelector('input[formcontrolname="email_or_nick"]')
          await page.type('input[formcontrolname="email_or_nick"]', process.env.LOGEMAIL)
          await page.type('input[formcontrolname="password"]', process.env.PASSWORD)
          await page.click('button[type="submit"]')
          await page.waitForSelector('div.popup-wrapper .btn-green-complement')
        })
        it("Logging out", async() => {
          await page.click('div.popup-wrapper .btn-green-complement')
          await page.click('.logged-in .login-btn')
          await page.waitForSelector('.desktop-login .login-details form')
        })
      })

      describe("User with completed profile login", async() => {
        describe("Basic User Type", async() => {
          it("Log in as basic user", async() => {
            await page.type('input[formcontrolname="email_or_nick"]', process.env.COMPMAIL)
            await page.type('input[formcontrolname="password"]', process.env.PASSWORD)
            await page.click('button[type="submit"]')
          })
          it("Check for User Type (at top right section of header)", async() => {
            await page.waitForSelector('app-member.swiper-slide.swiper-slide-active > div.profile-pic-wrapper > div.profile-pic')
            var basicText =  await page.$eval('div.login-wrapper.logged-in span', e => e.innerText)
            expect('BASIC SUBSCRIPTION').toEqual(basicText)
          })
          it("check smiley as per user type", async() => {
            await page.waitForSelector('div.login-wrapper.logged-in .fa-frown-o')
          })
          it("'Become Elite' button as per user type", async() => {
            var becomeElite = await page.$eval('div.desktop-nav button > span:nth-child(1)', e => e.innerText)
            expect('Become Elite').toEqual(becomeElite)
          })
        })
        describe("Elite User Type", async() => {
          it("Log out", async() => {
            await page.click('div.login-wrapper.logged-in > button')
          })
          it("Log in as Elite user", async() => {
            await page.waitForSelector('input[formcontrolname="email_or_nick"]')
            await page.type('input[formcontrolname="email_or_nick"]', process.env.ELITUSER)
            await page.type('input[formcontrolname="password"]', process.env.PASSWORD)
            await page.click('button[type="submit"]')
            await page.waitForSelector('.subscription-block h5 > span')
          })
          it("Check for User Type (at top right section of header)", async() => {
            var eliteText = await page.$eval('.subscription-block h5 > span', e => e.innerText)
            expect(eliteText).toEqual(expect.stringContaining('ELITE'))
          })
          it("check smiley as per user type", async() => {
            await page.waitForSelector('div.login-wrapper.logged-in .fa-smile-o')
          })
          it("Does not shows 'Become Elite' button", async() => {
            try {
              await page.waitForSelector('.desktop-nav .nav button', {timeout: 1000})
            }
            catch(err) {
              console.log('No Button in nav. Test Passed.')
            }
          })
        })
        describe("VIP User Type", async() => {
          it("Log out", async() => {
            await page.click('div.login-wrapper.logged-in > button')
          })
          it("Log in as VIP user", async() => {
            // await page.goto(baseUrl, {waitUntil: "networkidle0"})
            // await page.click('.login-btn')

            await page.waitForSelector('input[formcontrolname="email_or_nick"]')
            await page.type('input[formcontrolname="email_or_nick"]', process.env.VIPUSER)
            await page.type('input[formcontrolname="password"]', process.env.PASSWORD)
            await page.click('button[type="submit"]')
            await page.waitForSelector('app-dashboard app-desktop-header div.container > div.login-wrapper.logged-in > div > h5 > span')
          })
          it("Check for User Type (at top right section of header)", async() => {
            var vipText = await page.$eval('app-dashboard app-desktop-header div.container > div.login-wrapper.logged-in > div > h5 > span', e => e.innerText.split(' ')[1])
            expect(vipText).toEqual(expect.stringContaining('VIP'))
          })
          it("check smiley as per user type", async() => {
            await page.waitForSelector('app-dashboard app-desktop-header div.container > div.login-wrapper.logged-in > div > i.fa-smile-o')
          })
          it("Does not show 'Become Elite' button", async() => {
            try {
              await page.waitForSelector('.desktop-nav .nav button', {timeout: 1000})
            }
            catch(err) {
              console.log('No Button in nav. Test Passed.')
            }
          })
        })
      })
    })
  })
})

// DASHBOARD PAGE

describe("Dashboard Page", async() => {
  describe("Quick Search Cases", async() => {
    describe("Random search", async() => {
      it("logging in", async() => {
        await page.goto(baseUrl, {waitUntil: "networkidle0"})
        await page.click('.login-wrapper > button.login-btn')
        await page.waitForSelector('.login-details > form input[formcontrolname="email_or_nick"]')
        await page.type('input[formcontrolname="email_or_nick"]', process.env.USERNAME)
        await page.type('input[formcontrolname="password"]', process.env.PASSWORD)
        await page.click('button[type="submit"]')
        await page.waitForSelector('div.content-container .quick-search')
      })
      it("Selecting options randomly", async() => {
        await page.reload({waitUntil: "networkidle0"})
        let selectBoxesSelectors = [
          'div.quick-search select[formcontrolname="seeking"]',
          'div.quick-search select[formcontrolname="age"]',
          'div.quick-search select[formcontrolname="province_id"]'
        ]
        await page.selectRandom(selectBoxesSelectors, { multiple: true })
      })
      it("search and reached result page", async() => {
        await page.click('div.form-group .search-btn')
        await page.waitForSelector('div.member-list-wrapper')
      })
      it("search with only profile pics", async() => {
          const placeHolderImagesLength = await page.$$eval('div.member-list-wrapper app-member-list div.member-image-wrapper > div.member-image', (el, domain) => Array.from(el).map(e => e.style.backgroundImage).filter( e => e.indexOf(domain) > -1).length, api.split('.')[1] )
          expect(placeHolderImagesLength).toBe(0)
      })
    })
  
    describe("Search which has results", async() => {
      var lookingVal;
      var ageVal;
      var provinceVal;
      it("Selecting options which is known to provide results", async() => {
        await page.waitForSelector('.page-content-header .btn-black')
        await page.click('.page-content-header .btn-black')
        await page.waitForSelector('div.quick-search select')
        lookingVal = await page.$eval('div.quick-search select[formcontrolname="seeking"] > option:nth-child(3)', e => e.value)
        await page.select('div.quick-search select[formcontrolname="seeking"]', lookingVal)
        ageVal = await page.$eval('div.quick-search select[formcontrolname="age"] > option:nth-child(5)', e => e.value.split('-'))
        const ageForSelect = await page.$eval('div.quick-search select[formcontrolname="age"] > option:nth-child(5)', e => e.value)
        await page.select('div.quick-search select[formcontrolname="age"]', ageForSelect)
  
        await page.waitForFunction(() => document.querySelector('app-quick-search div.quick-search.row > div:nth-child(4) select').value, {polling: 'mutation'})
        provinceVal = await page.$eval('app-quick-search div.quick-search.row > div:nth-child(4) select > option:nth-child(32)', e => e.innerText)
        const provinceForSelect = await page.$eval('app-quick-search div.quick-search.row > div:nth-child(4) select > option:nth-child(32)', e => e.value)
        await page.select('app-quick-search div.quick-search.row > div:nth-child(4) select', provinceForSelect)
        await page.click('app-quick-search .form-group.only-photo.custom-checkbox > label.custom-check')
      })
      it("started search and reached result page with results", async() => {
        await page.click('div.form-group .search-btn')
        await page.waitForSelector('div.member-info > p')
      })
      it("comparing Age in search result", async () => {
        const ageResult = await page.$eval('div.member-info > p.member-address.member-age', e => +(e.innerText).split(' ')[0])
        expect(ageResult).toBeNull
        expect(ageResult).toBeLessThanOrEqual(+ageVal[1])
        expect(ageResult).toBeGreaterThanOrEqual(+ageVal[0])
      })
      it("comparing Province in search result", async () => {
        const provinceResult = await page.$eval('div.member-info > p:nth-child(3)', e => e.innerText)
        expect(provinceResult).toEqual(provinceVal)
      })
      it("search without profile pics", async() => {
        const placeHolderImagesLength = await page.$$eval('div.member-list-wrapper app-member-list div.member-image-wrapper > div.member-image', (el, domain) => Array.from(el).map(e => e.style.backgroundImage).filter( e => e.indexOf(domain) > -1).length, api.split('.')[1] )
        expect(placeHolderImagesLength).toBeGreaterThanOrEqual(1)
      })
    })
  
    describe("search with no result", async() => {
      it("Selecting options which is known to provide NO results", async () => {
        await page.click('.page-content-header .btn-black')
        lookingVal = await page.$eval('div.quick-search select[formcontrolname="seeking"] > option:nth-child(2)', e => e.value)
        await page.select('div.quick-search select[formcontrolname="seeking"]', lookingVal)
        const ageForSelect = await page.$eval('app-quick-search div.quick-search.row > div:nth-child(3) select > option:nth-child(8)', e => e.value)
        await page.select('app-quick-search div.quick-search.row > div:nth-child(3) select', ageForSelect)
      })
      it("started search and reached result page with info box showing 'no results'", async() => {
        await page.click('div.form-group .search-btn')
        await page.waitForSelector('div.no-favs .msg--info');
      })
    })
  })

  describe("Popular Member Carousel", async() => {

    it("Goto Home Page", async() => {
      await page.click(".side-menu li:nth-child(1)")
      await page.waitForSelector('div.content-container > swiper')
    })

    describe("Carousel Direction buttons", async() => {
      it("Clicking '<' moves carousel left", async() => {

        const nextIndex = 
                await page.$$eval('div.feature-profiles + swiper app-member', els => 
                          Array.from(els).findIndex( e => e.className.indexOf('swiper-slide-active') > -1 )) + 2;
        const nextName = await page.$eval(`div.feature-profiles + swiper app-member:nth-child(${nextIndex}) span.member-name`, el => el.innerHTML)
        await page.waitForSelector('div.feature-profiles i.icon-back.slide-one-prev')
        await page.click('div.feature-profiles i.icon-back.slide-one-prev')
        await page.waitFor(350)
        const activeIndex = 
        await page.$$eval('div.feature-profiles + swiper app-member', els => 
                  Array.from(els).findIndex( e => e.className.indexOf('swiper-slide-active') > -1 )) + 3;
        const activeName = await page.$eval(`div.feature-profiles + swiper app-member:nth-child(${activeIndex}) span.member-name`, el => el.innerHTML)
        expect(nextName).toBe(activeName);
      })
      it("Clicking '>' moves carousel right", async() => {
        const nextIndex = 
                await page.$$eval('div.feature-profiles + swiper app-member', els => 
                          Array.from(els).findIndex( e => e.className.indexOf('swiper-slide-active') > -1 )) + 2;
        const nextName = await page.$eval(`div.feature-profiles + swiper app-member:nth-child(${nextIndex}) span.member-name`, el => el.innerHTML)
        await page.waitForSelector('div.feature-profiles i.icon-next.slide-one-next')
        await page.click('div.feature-profiles i.icon-next.slide-one-next')
        await page.waitFor(350)
        const activeIndex = 
        await page.$$eval('div.feature-profiles + swiper app-member', els => 
                  Array.from(els).findIndex( e => e.className.indexOf('swiper-slide-active') > -1 )) + 1;
        const activeName = await page.$eval(`div.feature-profiles + swiper app-member:nth-child(${activeIndex}) span.member-name`, el => el.innerHTML)
        expect(nextName).toBe(activeName);
      })
    })

    describe("Carousel Drag", async() => {
      it("Dragging left moves carousel left", async() => {
        const middleIndex = 
                await page.$$eval('div.feature-profiles + swiper app-member', els => 
                          Array.from(els).findIndex( e => e.className.indexOf('swiper-slide-active') > -1 )) + 3;
        const middleName = await page.$eval(`div.feature-profiles + swiper app-member:nth-child(${middleIndex}) span.member-name`, el => el.innerHTML)
        const posTop = await page.$eval(`div.feature-profiles + swiper app-member:nth-child(${middleIndex})`, 
                                      el => el.getBoundingClientRect().top)
        const posLeft = await page.$eval(`div.feature-profiles + swiper app-member:nth-child(${middleIndex})`, 
                                      el => el.getBoundingClientRect().left)
        const itemWidth = await page.$eval(`div.feature-profiles + swiper app-member:nth-child(${middleIndex})`, 
                                      el => el.getBoundingClientRect().width)
        await page.mouse.move(posLeft + 50, posTop + 50)
        await page.mouse.down()
        await page.mouse.move(posLeft - (itemWidth * 2.0), posTop + 50)
        await page.mouse.up()
        const newMiddleIndex = 
                await page.$$eval('div.feature-profiles + swiper app-member', els => 
                          Array.from(els).findIndex( e => e.className.indexOf('swiper-slide-active') > -1 )) + 3;
        const newMiddleName = await page.$eval(`div.feature-profiles + swiper app-member:nth-child(${newMiddleIndex}) span.member-name`, el => el.innerHTML)
        expect(middleName).not.toBe(newMiddleName)
      })
      it("Dragging right moves carousel right", async() => {
        const middleIndex = 
        await page.$$eval('div.feature-profiles + swiper app-member', els => 
                  Array.from(els).findIndex( e => e.className.indexOf('swiper-slide-active') > -1 )) + 3;
        const middleName = await page.$eval(`div.feature-profiles + swiper app-member:nth-child(${middleIndex}) span.member-name`, el => el.innerHTML)
        const posTop = await page.$eval(`div.feature-profiles + swiper app-member:nth-child(${middleIndex})`, 
                                      el => el.getBoundingClientRect().top)
        const posLeft = await page.$eval(`div.feature-profiles + swiper app-member:nth-child(${middleIndex})`, 
                                      el => el.getBoundingClientRect().left)
        const itemWidth = await page.$eval(`div.feature-profiles + swiper app-member:nth-child(${middleIndex})`, 
                                      el => el.getBoundingClientRect().width)
        await page.mouse.move(posLeft + 50, posTop + 50)
        await page.mouse.down()
        await page.mouse.move(posLeft + (itemWidth * 2.0), posTop + 50)
        await page.mouse.up()
        const newMiddleIndex = 
                await page.$$eval('div.feature-profiles + swiper app-member', els => 
                          Array.from(els).findIndex( e => e.className.indexOf('swiper-slide-active') > -1 )) + 3;
        const newMiddleName = await page.$eval(`div.feature-profiles + swiper app-member:nth-child(${newMiddleIndex}) span.member-name`, el => el.innerHTML)
        expect(middleName).not.toBe(newMiddleName)
      })
    })

    describe("Adding Profile to Favorites (clicking empty Heart)", async() => {
      it(" 'Empty Heart' icon becomes 'Filled Heart' icon", async() => {
        await page.waitFor(500)
        await page.waitForSelector('div.feature-profiles + swiper app-member.swiper-slide-active span.fa.fa-heart-o')
        await page.click('div.feature-profiles + swiper app-member.swiper-slide-active span.fa.fa-heart-o')
        await page.waitForSelector('div.feature-profiles + swiper app-member.swiper-slide-active span.fa.fa-heart')
      })
      it(" 'Added to Favorites' success message appears", async() => {
        await page.waitForSelector('app-root > app-notification-list > div')
      })
    })

    describe("Removing Profile from Favorites (clicking filled Heart)", async() => {
      it(" 'Filled Heart' icon becomes 'Empty Heart' icon", async() => { 
        await page.waitForSelector('div.feature-profiles + swiper app-member.swiper-slide-active span.fa.fa-heart')
        await page.click('div.feature-profiles + swiper app-member.swiper-slide-active span.fa.fa-heart')
        await page.waitForSelector('div.feature-profiles + swiper app-member.swiper-slide-active span.fa.fa-heart-o')
      })
      it(" 'Removed from Favorites' success message appears", async() => {
        await page.waitForSelector('app-root > app-notification-list > div')
      })
    })
  })

  describe("New Member Carousel", async() => {
    describe("Carousel Direction buttons", async() => {
      it("Clicking '<' moves carousel left", async() => {
        const nextIndex = 
                await page.$$eval('div.new-member-wrapper swiper app-member', els => 
                          Array.from(els).findIndex( e => e.className.indexOf('swiper-slide-active') > -1 )) + 2;
        const nextName = await page.$eval(`div.new-member-wrapper swiper app-member:nth-child(${nextIndex}) span.member-name`, el => el.innerHTML)
        await page.waitForSelector('div.new-member-wrapper i.icon-back.slide-two-prev')
        await page.click('div.new-member-wrapper i.icon-back.slide-two-prev')
        await page.waitFor(500)
        const activeIndex = 
        await page.$$eval('div.new-member-wrapper swiper app-member', els => 
                  Array.from(els).findIndex( e => e.className.indexOf('swiper-slide-active') > -1 )) + 3;
        const activeName = await page.$eval(`div.new-member-wrapper swiper app-member:nth-child(${activeIndex}) span.member-name`, el => el.innerHTML)
        expect(nextName).toBe(activeName);
      })
      it("Clicking '>' moves carousel right", async() => {
        const nextIndex = 
                await page.$$eval('div.new-member-wrapper swiper app-member', els => 
                          Array.from(els).findIndex( e => e.className.indexOf('swiper-slide-active') > -1 )) + 2;
        const nextName = await page.$eval(`div.new-member-wrapper swiper app-member:nth-child(${nextIndex}) span.member-name`, el => el.innerHTML)
        await page.waitForSelector('div.new-member-wrapper i.icon-next.slide-two-next')
        await page.click('div.new-member-wrapper i.icon-next.slide-two-next')
        await page.waitFor(500)
        const activeIndex = 
        await page.$$eval('div.new-member-wrapper swiper app-member', els => 
                  Array.from(els).findIndex( e => e.className.indexOf('swiper-slide-active') > -1 )) + 1;
        const activeName = await page.$eval(`div.new-member-wrapper swiper app-member:nth-child(${activeIndex}) span.member-name`, el => el.innerHTML)
        expect(nextName).toBe(activeName);
      })
    })
    describe("Carousel Drag", async() => {
      it("Dragging left moves carousel left", async() => {
        const middleIndex = 
                await page.$$eval('div.new-member-wrapper swiper app-member', els => 
                          Array.from(els).findIndex( e => e.className.indexOf('swiper-slide-active') > -1 )) + 3;
        const middleName = await page.$eval(`div.new-member-wrapper swiper app-member:nth-child(${middleIndex}) span.member-name`, el => el.innerHTML)
        const posTop = await page.$eval(`div.new-member-wrapper swiper app-member:nth-child(${middleIndex})`, 
                                      el => el.getBoundingClientRect().top)
        const posLeft = await page.$eval(`div.new-member-wrapper swiper app-member:nth-child(${middleIndex})`, 
                                      el => el.getBoundingClientRect().left)
        const itemWidth = await page.$eval(`div.new-member-wrapper swiper app-member:nth-child(${middleIndex})`, 
                                      el => el.getBoundingClientRect().width)
        await page.mouse.move(posLeft + 50, posTop + 50)
        await page.mouse.down()
        await page.mouse.move(posLeft - (itemWidth * 2.0), posTop + 50)
        await page.mouse.up()
        const newMiddleIndex = 
                await page.$$eval('div.new-member-wrapper swiper app-member', els => 
                          Array.from(els).findIndex( e => e.className.indexOf('swiper-slide-active') > -1 )) + 3;
        const newMiddleName = await page.$eval(`div.new-member-wrapper swiper app-member:nth-child(${newMiddleIndex}) span.member-name`, el => el.innerHTML)
        expect(middleName).not.toBe(newMiddleName)
      })
      it("Dragging right moves carousel right", async() => {
        const middleIndex = 
        await page.$$eval('div.new-member-wrapper swiper app-member', els => 
                  Array.from(els).findIndex( e => e.className.indexOf('swiper-slide-active') > -1 )) + 3;
        const middleName = await page.$eval(`div.new-member-wrapper swiper app-member:nth-child(${middleIndex}) span.member-name`, el => el.innerHTML)
        const posTop = await page.$eval(`div.new-member-wrapper swiper app-member:nth-child(${middleIndex})`, 
                                      el => el.getBoundingClientRect().top)
        const posLeft = await page.$eval(`div.new-member-wrapper swiper app-member:nth-child(${middleIndex})`, 
                                      el => el.getBoundingClientRect().left)
        const itemWidth = await page.$eval(`div.new-member-wrapper swiper app-member:nth-child(${middleIndex})`, 
                                      el => el.getBoundingClientRect().width)
        await page.mouse.move(posLeft + 50, posTop + 50)
        await page.mouse.down()
        await page.mouse.move(posLeft + (itemWidth * 2.0), posTop + 50)
        await page.mouse.up()
        const newMiddleIndex = 
                await page.$$eval('div.new-member-wrapper swiper app-member', els => 
                          Array.from(els).findIndex( e => e.className.indexOf('swiper-slide-active') > -1 )) + 3;
        const newMiddleName = await page.$eval(`div.new-member-wrapper swiper app-member:nth-child(${newMiddleIndex}) span.member-name`, el => el.innerHTML)
        expect(middleName).not.toBe(newMiddleName)
      })
    })
    describe("Adding Profile to Favorites (clicking empty Heart)", async() => {
      it(" 'Empty Heart' icon becomes 'Filled Heart' icon", async() => {
        await page.waitFor(500)
        await page.waitForSelector('div.new-member-wrapper app-member.swiper-slide-active span.fa.fa-heart-o')
        await page.click('div.new-member-wrapper app-member.swiper-slide-active span.fa.fa-heart-o')
        await page.waitForSelector('div.new-member-wrapper app-member.swiper-slide-active span.fa.fa-heart')
      })
      it(" 'Added to Favorites' success message appears", async() => {
        await page.waitForSelector('app-root > app-notification-list > div')
      })
    })
    describe("Removing Profile from Favorites (clicking filled Heart)", async() => {
      it(" 'Filled Heart' icon becomes 'Empty Heart' icon", async() => {
        await page.click('div.new-member-wrapper app-member.swiper-slide-active span.fa.fa-heart')
        await page.waitForSelector('div.new-member-wrapper app-member.swiper-slide-active span.fa.fa-heart-o')
      })
      it(" 'Removed from Favorites' success message appears", async() => {
        await page.waitForSelector('app-root > app-notification-list > div')
      })
    })
  })

  describe("Recent Activity", async() => {
    describe("Adding Profile to Favorites (clicking empty Heart)", async() => {
      it(" 'Empty Heart' icon becomes 'Filled Heart' icon", async() => {
        await page.waitForSelector('app-recent-activity span.fa.fa-heart-o')
        await page.click("app-recent-activity span.fa.fa-heart-o")
        await page.waitForSelector('app-recent-activity span.fa.fa-heart')
      })
      it(" 'Added to Favorites' success message appears", async() => {
        await page.waitForSelector('app-root > app-notification-list > div')
      })
    })
    describe("Removing Profile from Favorites (clicking filled Heart)", async() => {
      it(" 'Filled Heart' icon becomes 'Empty Heart' icon", async() => {
        await page.waitForSelector('app-recent-activity span.fa.fa-heart')
        await page.click("app-recent-activity span.fa.fa-heart")
        await page.waitForSelector('app-recent-activity span.fa.fa-heart-o')
      })
      it(" 'Removed from Favorites' success message appears", async() => {
        await page.waitForSelector('app-root > app-notification-list > div')
      })
    })
  })
})

// SUPPORT / CONTACT PAGE

describe("Support/Contact Page", async() => {
  it("GoTo Contact Page", async() => {
    await page.goto(baseUrl, {waitUntil: 'networkidle0'})
    await page.waitForSelector('app-footer div.col-sm-4.nav--col > ul > li:nth-child(1) > a')
    await page.click('app-footer div.col-sm-4.nav--col > ul > li:nth-child(1) > a')
  })
  describe("Accordion", async() => {
    var randomAccordian

    it("Initial setup", async () => {
      await page.waitForSelector('app-footer div.col-sm-4.nav--col > ul > li:nth-child(1) > a')
      await page.click('app-footer div.col-sm-4.nav--col > ul > li:nth-child(1) > a')
      await page.waitForSelector('div.page-content-header')
      var accordionLength = await page.$$eval('app-contact app-accordion', e => e.length)
      await page.waitForFunction(() => document.querySelectorAll("app-contact app-accordion"), e => e.length === accordionLength)
      randomAccordian = await page.$$eval('app-contact app-accordion',
        e => Math.floor(Math.random() * e.length)
      )
    })

    describe("Accordion expand", async () => {
      it("Check initial arrow direction", async () => {
        await page.waitForSelector(`app-contact app-accordion:nth-of-type(${+randomAccordian + 1}) .accordion--arrow .icon-down-arrow-of-angle`)
      })
      it("Expand & check content + arrow", async () => {
        await page.click(`app-contact app-accordion:nth-of-type(${+randomAccordian + 1})`)
        await page.waitForSelector(`app-contact app-accordion:nth-of-type(${+randomAccordian + 1}) .accordion--arrow .icon-up-arrow-angle`)
        await page.waitForSelector(`app-contact app-accordion:nth-of-type(${+randomAccordian + 1}) .accordion--content`)
      })
    })

    describe("Accordian collapse", async() => {
      it("Check initial arrow direction", async() => {
        await page.waitForSelector(`app-contact app-accordion:nth-of-type(${+randomAccordian + 1}) .accordion--arrow .icon-up-arrow-angle`)
      })
      it("collapse & check content + arrow", async() => {
        await page.click(`app-contact app-accordion:nth-of-type(${+randomAccordian + 1}) .accordion--title`)
        await page.waitForSelector(`app-contact app-accordion:nth-of-type(${+randomAccordian + 1}) .accordion--arrow .icon-down-arrow-of-angle`)
        await page.waitForSelector(`app-contact app-accordion:nth-of-type(${+randomAccordian + 1}) .accordion--content`, {hidden: true})
      })
    })

    describe("open random accordian and click on another random accordian close previously opened accordian", async() => {
      var openRandomAccord
      var closeRandomAccord
      it("expand random accordian and check for arrow and content", async() => {
        openRandomAccord = await page.$$eval('app-contact app-accordion',
          e => Math.floor(Math.random() * e.length)
        )
        await page.waitForSelector(`app-contact app-accordion:nth-of-type(${+openRandomAccord + 1}) .accordion--arrow .icon-down-arrow-of-angle`)
        await page.waitForSelector(`app-contact app-accordion:nth-of-type(${+openRandomAccord + 1}) .accordion--content`, {hidden: true})
        await page.click(`app-contact app-accordion:nth-of-type(${+openRandomAccord + 1}) .accordion--title`)
        await page.waitForSelector(`app-contact app-accordion:nth-of-type(${+openRandomAccord + 1}) .accordion--arrow .icon-up-arrow-angle`)
        await page.waitForSelector(`app-contact app-accordion:nth-of-type(${+openRandomAccord + 1}) .accordion--content`)
      })
      // it("opening another random accordian and check for previous accordian arrow and content", async() => {
      it('1', async() => {
        closeRandomAccord = await page.$$eval('app-contact app-accordion',
          e => Math.floor(Math.random() * e.length)
        )
      })
      it('2', async() => {
        // await page.waitForFunction(() => document.querySelector(`app-contact app-accordion:nth-of-type(7) div.accordion--title-text`).innerText.length > 2, { polling: 'mutation' })
        const downArrow = await page.$$eval('app-contact app-accordion .accordion--arrow > span.icon-down-arrow-of-angle', e => e.length)
        await page.waitForFunction(() => document.querySelectorAll('app-contact app-accordion .accordion--arrow > span.icon-down-arrow-of-angle'), e => e.length === downArrow)
      })
      it.skip('3', async() => {
        // await page.waitForFunction(() => document.querySelector(`app-contact app-accordion:nth-of-type(${+closeRandomAccord + 1}) .accordion--arrow .icon-down-arrow-of-angle`).localName === 'span', { polling: 'mutation' })
        await page.waitFor(3000)
        await page.waitForSelector(`app-contact app-accordion:nth-of-type(${+closeRandomAccord + 1}) .accordion--arrow > span.icon-down-arrow-of-angle`)
      })
      it('4', async() => {
        await page.click(`app-contact app-accordion:nth-of-type(${+closeRandomAccord + 1}) .accordion--title`)
      })
      it.skip('5', async() => {
        await page.waitFor(3000)
        await page.waitForSelector(`app-contact app-accordion:nth-of-type(${+closeRandomAccord + 1}) .accordion--arrow .icon-up-arrow-angle`)
      })
      it.skip('6', async() => {
        await page.waitFor(3000)
        await page.waitForSelector(`app-contact app-accordion:nth-of-type(${+closeRandomAccord + 1}) .accordion--content`)
      })
      it('7', async() => {
        await page.waitForSelector(`app-contact app-accordion:nth-of-type(${+openRandomAccord + 1}) .accordion--arrow .icon-down-arrow-of-angle`)
      })
      it('8', async() => {
        await page.waitForSelector(`app-contact app-accordion:nth-of-type(${+openRandomAccord + 1}) .accordion--content`, {hidden: true})
      })
      it('9', async() => {
        await page.waitFor(3000)
      })
      // })
    })
  })
  describe("Error Checks", async() => {
    it("Submitting form without filling any field", async() => {
      await page.waitForSelector('app-contact-form div.heading-wrapper')
      await page.click('app-contact-form div.heading-wrapper')
      await page.waitForSelector('#form-wrapper > form > div:nth-child(8) > button')
      await page.click('#form-wrapper > form > div:nth-child(8) > button')
      await page.waitForSelector('#form-wrapper > form > div:nth-child(1) > div.msg.msg--error')
      await page.waitForSelector('#form-wrapper > form > div:nth-child(2) > div.msg.msg--error')
      await page.waitForSelector('#form-wrapper > form > div:nth-child(3) > div.msg.msg--error')
      await page.waitForSelector('#form-wrapper > form > div:nth-child(4) > div.msg.msg--error')
      await page.waitForSelector('#form-wrapper > form > div:nth-child(5) > div.msg.msg--error')
      await page.waitForSelector('#form-wrapper > form > div:nth-child(6) > div.msg.msg--error')
      await page.waitForSelector('#form-wrapper > form > div:nth-child(7) > div.msg.msg--error')
    })
    it("Check if captcha loads successfully", async() => {
      await page.waitForSelector('#ngrecaptcha-0')
    })
  })
  describe("Valid form submit", async() => {
    it("Valid form submit", async() => {
      await page.type('#form-wrapper > form > div:nth-child(2) > input', 'rajdeep')
      await page.type('#form-wrapper > form > div:nth-child(3) > input', 'This Is Test Subject')
      await page.type('#form-wrapper > form > div:nth-child(4) > input', 'rajdeep@itobuz.com')
      await page.type('#form-wrapper > form > div:nth-child(5) > input', 'rajdeep@itobuz.com')
      await page.type('#form-wrapper textarea', 'This is my test message to submit form')
      await page.click('#form-wrapper > form > div:nth-child(8) > button')
      await page.waitForSelector('#form-wrapper > form > div:nth-child(7) > div.msg.msg--error')
    })
  })
})

// MESSAGE LIST PAGE (( SKIP THIS ONE ))

describe("Message List Page", async() => {
  it("Login as Prosenjit", async() => {
    await page.goto(baseUrl, {waitUntil: "networkidle0"})
    await page.click('.login-btn')
    await page.waitForSelector('app-login form > input:nth-child(2)')
    await page.type('app-login form > input:nth-child(2)', process.env.USERNAME_P)
    await page.type('app-login form > input:nth-child(4)', process.env.PASSWORD)
    await page.click('app-login form > button')
    await page.waitForSelector('app-desktop-sidebar div.side-menu > ul > li:nth-child(2)')
    await page.click('app-desktop-sidebar div.side-menu > ul > li:nth-child(2)')
    // await page.waitForSelector('div.message-list')
  })
  describe.skip("Message Select and Delete cases", async() => {
    describe("Select single message", async() => {
      it("Selected message gets 'checked' symbol", async() => {
        await page.waitForSelector('div.message-list-wrapper label.label--material-checkbox.gotoDetails')
        await page.click('div.message-list-wrapper label.label--material-checkbox.gotoDetails')
        await page.waitForSelector('div.message-list-wrapper label.label--material-checkbox.gotoDetails.active')
      })
      it(" 'Selected messages' number (at the top-right button 'Delete Selected') increase by 1", async() => {
        const count = await page.$eval('div.group-btns > button:nth-child(2) > span.pl-2.pr-3', el => el.innerHTML)
        expect(count).toContain('1')
      })
    })
    describe("Delete single message", async() => {
      it("Selected message is deleted", async() => {
        var chatName = await page.$eval('div.message-list-wrapper div.message-list-info > p.message-history', el => el.innerHTML)
        await page.click('div.page-content-header > div.group-btns > button:nth-child(2)')
        await page.waitForFunction( (e) => !Array.from(document.querySelectorAll('div.message-list')).map(e => e.innerText.split('\n').shift()).includes(e), {polling: 'mutation'}, chatName)
        var namesArray = await page.$$eval('div.message-list', els => Array.from(els).map(e => e.innerText.split('\n').shift()))
        expect(namesArray).not.toContain(chatName)
      })
      it(" 'Selected messages' number (at the top-right button 'Delete Selected') decrease by 1", async() => {
        await page.waitForFunction( () => document.querySelector('div.group-btns > button:nth-child(2) > span.pl-2.pr-3').innerHTML.indexOf('0') != -1 )
        const count = await page.$eval('div.group-btns > button:nth-child(2) > span.pl-2.pr-3', el => el.innerHTML)
        expect(count).toContain('0')
      })
    })
    describe("Select multiple messages", async() => {
      it("Selected message gets 'checked' symbol", async() => {
        await page.waitForSelector('div.content-container > div:nth-child(4) > button')
        await page.click('div.content-container > div:nth-child(4) > button')
        const messagesLength = await page.$$eval('div.message-list', els => Array.from(els).length)
        await page.waitForFunction( (e) => Array.from(document.querySelectorAll('div.message-list-wrapper label.label--material-checkbox.gotoDetails.active')).length ==e , {polling: 'mutation'}, messagesLength)
        const tickLength = await page.$$eval('div.message-list-wrapper label.label--material-checkbox.gotoDetails.active', els => Array.from(els).length)
        expect(messagesLength).toEqual(tickLength)
      })
      it("'Selected messages' number (at the top-right button 'Delete Selected') increase by 'total selected messages'", async() => {
        const messagesLength = await page.$$eval('div.message-list', els => Array.from(els).length)
        const count = await page.$eval('div.group-btns > button:nth-child(2) > span.pl-2.pr-3', el => el.innerHTML)
        expect(count).toContain(messagesLength)
      })
      it('deselect all', async() => {
        await page.click('div.content-container > div:nth-child(4) > button')
      })
    })
    describe("Delete multiple messages", async() => {
      it("Selected messages are deleted", async() => {
        await page.waitForSelector('app-my-chat div.content-container > div.message-list-wrapper > div.message-list.unread > div > div.message-list-image')
        let selectCheck = [
          'app-my-chat div.content-container > div.message-list-wrapper > div.message-list:nth-child(1) > label',
          'app-my-chat div.content-container > div.message-list-wrapper > div.message-list:nth-child(2) > label',
          'app-my-chat div.content-container > div.message-list-wrapper > div.message-list:nth-child(3) > label',
          'app-my-chat div.content-container > div.message-list-wrapper > div.message-list:nth-child(4) > label',
          'app-my-chat div.content-container > div.message-list-wrapper > div.message-list:nth-child(5) > label',
          'app-my-chat div.content-container > div.message-list-wrapper > div.message-list:nth-child(6) > label',
        ]
        await page.checkRandom(selectCheck)
        const checkedArr = await page.$$eval('app-my-chat div.content-container > div.message-list-wrapper > div.message-list > label.active + .message-list-dtl .message-list-info .message-history', e => Array.from(e).map(el => el.innerText))
        const checkedArrLengh = await page.$$eval('app-my-chat div.content-container > div.message-list-wrapper > div.message-list > label.active', e => Array.from(e).length)
        const count = await page.$eval('div.group-btns > button:nth-child(2) > span.pl-2.pr-3', el => +el.innerHTML.split('')[1])
        expect(count).toEqual(checkedArrLengh)
        await page.click('app-my-chat div.content-container > div.page-content-header.d-flex > div.group-btns > button:nth-child(2)')
        var namesArray = await page.$$eval('div.message-list', els => Array.from(els).map(e => e.innerText.split('\n').shift()))
        expect(namesArray).not.toContain(checkedArr)
        console.log(namesArray)
        console.log(checkedArr)
        await page.waitFor(3000)
      })
      it(" 'Selected messages' number (at the top-right button 'Delete Selected') decreases by 'total selected message number'", async() => {
        await page.waitForFunction( () => document.querySelector('div.group-btns > button:nth-child(2) > span.pl-2.pr-3').innerHTML.indexOf('0') != -1 )
        const count = await page.$eval('div.group-btns > button:nth-child(2) > span.pl-2.pr-3', el => el.innerHTML)
        expect(count).toContain('0')
        await page.waitFor(3000)
      })
    })
  })
})

// TRASH PAGE

describe("Trash Page", async() => {
  var oldChatName, newChatName;
  it("Goto Trash Page", async() => {
    await page.waitForSelector('app-my-chat div.page-content-header > div.group-btns > button:nth-child(1)')
    await page.click('app-my-chat div.page-content-header > div.group-btns > button:nth-child(1)')
    await page.reload({waitUntil: 'networkidle0'})
  })
  it("Click next page", async() => {
    await page.waitForSelector('p.message-history')
    oldChatName = await page.$eval('p.message-history', e => e.innerText)
    await page.click('app-chat-trash div.pagination > button > span.pr-2')
  })
  it("Show loader and navigates", async() => {
    await page.waitForSelector('.loader')
    await page.waitForSelector('p.message-history')
    await page.waitForFunction((oldChatName) => document.querySelector('p.message-history').innerText !== oldChatName, {polling: 'mutation'}, oldChatName)
    newChatName = await page.$eval('p.message-history', e => e.innerText)
    expect(oldChatName).not.toBe(newChatName)
  })
  it("Click previous page", async() => {
    await page.click("app-chat-trash div.pagination > button:nth-child(1) > span.pl-2")
  })
  it("Show loader and navigates", async() => {
    await page.waitForSelector('.loader')
    await page.waitForSelector('p.message-history')
    await page.waitForFunction((oldChatName) => document.querySelector('p.message-history').innerText == oldChatName, {polling: 'mutation'}, oldChatName)
    prevChatName = await page.$eval('p.message-history', e => e.innerText)
    expect(prevChatName).toBe(oldChatName)
  })
})

// MESSAGE DETAIL PAGE

describe("Message Detail page", async() => {
  it("login", async() => {
    await page.goto(baseUrl, {waitUntil: "networkidle0"})
    await page.click(".login-btn")
    await page.waitForSelector('.login-details > form')
    await page.type('input[formcontrolname="email_or_nick"]', process.env.ELITUSER)
    await page.type('input[formcontrolname="password"]', process.env.PASSWORD)
    await page.click('button[type="submit"]')
    await page.waitForSelector('.subscription-block')
  })
  it("goes to send message page", async() => {
    await page.waitForSelector('div.desktop-nav ul > li > a')
    await page.click('div.desktop-nav ul > li:nth-child(1) > a')

    await page.waitForSelector('div.desktop-nav ul > li > a')
    await page.click('div.desktop-nav ul > li:nth-child(4) > a')

    await page.waitForSelector('div.member-info > div.like-list-wrapper')
    await page.click('div.like-list-wrapper > span.icon-envelope.icon-c')
  })
  describe("Error cases", async() => {
    describe("Blank message", async() => {
      it("Sending blank message", async() => {
        await page.waitForSelector('div.chat-typing-area > form .btn-green-complement')
        await page.click('div.chat-typing-area > form .btn-green-complement')
      })
      it("Error displayed", async() => {
        await page.$eval('div.chat-typing-area > form .msg.msg--error', e => {
          setTimeout(function () {
            e.style.display='none';
          }, 5000);
          return false;
        })
      })
    })
    describe("Sending single character in message", async() => {
      it("Sending single character", async() => {
        await page.type('div.chat-typing-area .textarea-wrapper > textarea', 'm')
        await page.click('div.chat-typing-area > form .btn-green-complement')
      })
      it("Error displayed", async() => {
        var twoCharacters = await page.$eval('div.chat-typing-area > form .msg.msg--error', e => e.innerText)
        expect('The message must be at least 2 characters.').toEqual(twoCharacters)
      })
    })
  })
  describe('Message 500 letters limitation', async() => {
    it('characters left count check', async() => {
      await page.reload({ waitUntil: "networkidle0" })
      // await page.$eval('app-chat-detail div.content-container > div.chat-typing-area > form > div > div.textarea-wrapper > textarea', e => e.value = '')
      await page.type('app-chat-detail div.content-container > div.chat-typing-area > form > div > div.textarea-wrapper > textarea', message)
      const textLength = await page.$eval('app-chat-detail div.content-container > div.chat-typing-area > form > div > div.textarea-wrapper > textarea', e => e.textLength) 
      await page.waitFor(3000)
      const remaining = await page.$eval('app-chat-detail div.content-container > div.chat-typing-area > form > p:nth-child(3) > span', e => +e.innerText.split(' ')[0]) 
      expect(500 - textLength).toEqual(remaining)
    })
    it("cant type more than 500 letters", async() => {
      await page.type('app-chat-detail div.content-container > div.chat-typing-area > form > div > div.textarea-wrapper > textarea', paras)
      const textLength = await page.$eval('app-chat-detail div.content-container > div.chat-typing-area > form > div > div.textarea-wrapper > textarea', e => e.textLength) 
      await page.waitFor(3000)
      const zero = await page.$eval('app-chat-detail div.content-container > div.chat-typing-area > form > p:nth-child(3) > span', e => +e.innerText.split(' ')[0]) 
      expect(500 - textLength).toEqual(zero)
    })
  })
  describe("Success cases", async() => {
    describe("Basic User", async() => {
      it("Login as Basic", async() => {
        await page.goto(baseUrl, {waitUntil: "networkidle0"})
        await page.click(".login-btn")
        await page.waitForSelector('app-login form > input:nth-child(2)')
        await page.type('app-login form > input:nth-child(2)', process.env.USERNAME)
        await page.type('app-login form > input:nth-child(4)', process.env.PASSWORD)
        await page.click('app-login form > button')
        await page.waitForSelector('body app-desktop-sidebar')
      })
      it("Sending message", async() => {
        await page.waitForSelector('swiper app-member.swiper-slide.swiper-slide-active > div.profile-pic-wrapper > div.member-icon-wrapper.d-flex.flex-row > div:nth-child(2)')
        await page.click('swiper app-member.swiper-slide.swiper-slide-active > div.profile-pic-wrapper > div.member-icon-wrapper.d-flex.flex-row >  div:nth-child(2)')
        await page.waitForSelector('div.chat-typing-area > form textarea')
        await page.type('div.chat-typing-area > form textarea', 'Hi There Wassup??')
        await page.click('div.chat-typing-area > form button.btn-green-complement')
      })
      it("Redirected to Payment/Subscription page", async() => {
        await page.waitForSelector('app-payment div.msg.msg--info.text-center')
      })
    })
    describe.skip("Elite User", async() => {  // to check
      var i = 0;
      it("Login as Elite", async() => {
        await page.goto(baseUrl, {waitUntil: "networkidle0"})
        await page.click(".login-btn")
        await page.waitForSelector('app-login form > input:nth-child(2)')
        await page.type('app-login form > input:nth-child(2)', process.env.VIPUSER)
        await page.type('app-login form > input:nth-child(4)', process.env.PASSWORD)
        await page.click('app-login form > button')
        await page.waitForSelector('app-free-msg')
        await page.click('div.desktop-nav ul > li:nth-child(1) a')
        await page.waitForSelector('div.content-container > swiper')
      })
      it("Sending single message to 5 random but different users", async() => {
        const activeIndex = await page.$$eval('div.content-container > swiper app-member', els => Array.from(els).findIndex( e => e.className.indexOf('swiper-slide-active') > -1 ) ) + 1
        for (i = activeIndex; i < activeIndex + 5; i++) {
          await page.click(`div.content-container > swiper app-member:nth-child(${i}) span.icon-envelope-solid`)
          await page.waitForSelector('div.chat-typing-area > form textarea')
          await page.type('div.chat-typing-area > form textarea', 'Wasssup ???')
          await page.click('div.chat-typing-area > form button.btn-green-complement')
          await page.waitForSelector('div.chat-box-wrapper > div:nth-child(1)')
          await page.click('app-desktop-sidebar div.side-menu > ul > li:nth-child(1)')
          await page.waitForSelector('div.content-container > swiper')
        }
      })
      it("Message to 6th user", async() => {
        await page.click('div.feature-profiles i.icon-next.slide-one-next')
        await page.waitFor(500)
        await page.click(`div.content-container > swiper app-member:nth-child(${i}) span.icon-envelope-solid`)
        await page.waitForSelector('div.chat-typing-area > form textarea')
        await page.type('div.chat-typing-area > form textarea', 'Wasssup ???')
        await page.click('div.chat-typing-area > form button.btn-green-complement')
      })
      it("Redirected to Payment/Subscription page on messaging 6th different user", async() => {
        await page.waitForSelector('app-payment div.msg.msg--info.text-center')
      })
    })
  })
  
})

// FAQ Page

describe("Faq page", async() => {
  describe("Accordion", async() => {
    var randomAccordian

    it("Initial setup", async () => {
      await page.goto(baseUrl, {waitUntil: "networkidle0"})
      await page.waitForSelector('app-footer div.col-sm-4.site--info.text-right > div.nav--col > ul > li:nth-child(2) > a')
      await page.click('app-footer div.col-sm-4.site--info.text-right > div.nav--col > ul > li:nth-child(2) > a')
      await page.waitForSelector('div.page-content-header')
      var accordionLength = await page.$$eval('app-faq app-accordion', e => e.length)
      await page.waitForFunction(() => document.querySelectorAll("app-faq app-accordion"), e => e.length === accordionLength)
      randomAccordian = await page.$$eval('app-faq app-accordion',
        e => Math.floor(Math.random() * e.length)
      )
    })
    describe("Accordion expand", async () => {
      it("Check initial arrow direction", async () => {
        await page.waitForSelector(`app-faq app-accordion:nth-of-type(${+randomAccordian + 1}) .accordion--arrow .icon-down-arrow-of-angle`)
      })
      it("Expand & check content + arrow", async () => {
        await page.click(`app-faq app-accordion:nth-of-type(${+randomAccordian + 1})`)
        await page.waitForSelector(`app-faq app-accordion:nth-of-type(${+randomAccordian + 1}) .accordion--arrow .icon-up-arrow-angle`)
        await page.waitForSelector(`app-faq app-accordion:nth-of-type(${+randomAccordian + 1}) .accordion--content`)
      })
    })
    describe("Accordian collapse", async() => {
      it("Check initial arrow direction", async() => {
        await page.waitForSelector(`app-faq app-accordion:nth-of-type(${+randomAccordian + 1}) .accordion--arrow .icon-up-arrow-angle`)
      })
      it("collapse & check content + arrow", async() => {
        await page.click(`app-faq app-accordion:nth-of-type(${+randomAccordian + 1}) .accordion--title`)
        await page.waitForSelector(`app-faq app-accordion:nth-of-type(${+randomAccordian + 1}) .accordion--arrow .icon-down-arrow-of-angle`)
        await page.waitForSelector(`app-faq app-accordion:nth-of-type(${+randomAccordian + 1}) .accordion--content`, {hidden: true})
      })
    })
    // new
    describe("open random accordian and click on another random accordian close previously opened accordian", async() => {
      var openRandomAccord
      it("expand random accordian and check for arrow and content", async() => {
        openRandomAccord = await page.$$eval('app-faq app-accordion',
          e => Math.floor(Math.random() * e.length)
        )
        await page.waitForSelector(`app-faq app-accordion:nth-of-type(${+openRandomAccord + 1}) .accordion--arrow .icon-down-arrow-of-angle`)
        await page.waitForSelector(`app-faq app-accordion:nth-of-type(${+openRandomAccord + 1}) .accordion--content`, {hidden: true})
        await page.click(`app-faq app-accordion:nth-of-type(${+openRandomAccord + 1}) .accordion--title`)
        await page.waitForSelector(`app-faq app-accordion:nth-of-type(${+openRandomAccord + 1}) .accordion--arrow .icon-up-arrow-angle`)
        await page.waitForSelector(`app-faq app-accordion:nth-of-type(${+openRandomAccord + 1}) .accordion--content`)
      })
      it("opening another random accordian and check for previous accordian arrow and content", async() => {
        var closeRandomAccord = await page.$$eval('app-faq app-accordion',
          e => Math.floor(Math.random() * e.length)
        )
        await page.waitForSelector(`app-faq app-accordion:nth-of-type(${+closeRandomAccord + 1}) .accordion--arrow .icon-down-arrow-of-angle`)
        await page.click(`app-faq app-accordion:nth-of-type(${+closeRandomAccord + 1}) .accordion--title`)
        await page.waitForSelector(`app-faq app-accordion:nth-of-type(${+closeRandomAccord + 1}) .accordion--arrow .icon-up-arrow-angle`)
        await page.waitForSelector(`app-faq app-accordion:nth-of-type(${+closeRandomAccord + 1}) .accordion--content`)
        await page.waitForSelector(`app-faq app-accordion:nth-of-type(${+openRandomAccord + 1}) .accordion--arrow .icon-down-arrow-of-angle`)
        await page.waitForSelector(`app-faq app-accordion:nth-of-type(${+openRandomAccord + 1}) .accordion--content`, {hidden: true})
        await page.waitFor(3000)
        // it("1", async() => {
        //   await page.waitForSelector(`app-faq app-accordion:nth-of-type(${+closeRandomAccord + 1}) .accordion--arrow .icon-down-arrow-of-angle`)
        // })
        // it("2", async() => {
        // await page.click(`app-faq app-accordion:nth-of-type(${+closeRandomAccord + 1}) .accordion--title`)          
        // })
        // it("3", async() => {
        // await page.waitForSelector(`app-faq app-accordion:nth-of-type(${+closeRandomAccord + 1}) .accordion--arrow .icon-up-arrow-angle`)          
        // })
        // it("4", async() => {
        // await page.waitForSelector(`app-faq app-accordion:nth-of-type(${+closeRandomAccord + 1}) .accordion--content`)          
        // })
        // it("5", async() => {
        // await page.waitForSelector(`app-faq app-accordion:nth-of-type(${+openRandomAccord + 1}) .accordion--arrow .icon-down-arrow-of-angle`)          
        // })
        // it("6", async() => {
        // await page.waitForSelector(`app-faq app-accordion:nth-of-type(${+openRandomAccord + 1}) .accordion--content`, {hidden: true})          
        // })
        // await page.waitFor(3000)
      })
    })
  })
})

/**************************** PHASE 2 *******************************/

// SETTINGS PAGE

describe("Settings Page", async() => {
  describe("Account type check", async() => {
    describe("Check Elite Account Type", async() => {
      it("Login as Elite", async() => {
        await page.goto(baseUrl, {waitUntil: "networkidle0"})
        await page.click('.login-btn')
        await page.waitForSelector('app-login form > input:nth-child(2)')
        await page.type('app-login form > input:nth-child(2)', process.env.ELITE_USERNAME)
        await page.type('app-login form > input:nth-child(4)', process.env.PASSWORD)
        await page.click('app-login form > button')
        await page.waitForSelector('app-free-msg')
        await page.click('div.desktop-nav ul > li:nth-child(1) a')
        await page.waitForSelector('div.content-container > swiper')
      })
      it("Goto Settings", async() => {
        await page.waitForSelector('div.desktop-nav ul > li:nth-child(6) > a')
        await page.click('div.desktop-nav ul > li:nth-child(6) > a')
        await page.waitForSelector('form > div.submit-row.text-center > button')
      })
      it("Check Account Type", async() => {
        await page.waitForSelector("app-desktop-sidebar li.member-menu-wrapper > span.member-badge")
        const sidebarSubType = await page.$eval("app-desktop-sidebar li.member-menu-wrapper > span.member-badge", el => el.innerText)
        await page.waitForSelector("app-settings form > div:nth-child(6) > span.icon-down-arrow-of-angle.icon")
        await page.click("app-settings form > div:nth-child(6) > span.icon-down-arrow-of-angle.icon")
        await page.waitForSelector("div.settings-subscription div:nth-child(1) > p > strong")
        const accountSubType = await page.$eval("div.settings-subscription div:nth-child(1) > p > strong", el => el.innerText)
        expect(sidebarSubType).toBe(accountSubType)
      })
      it("logout", async() => {
        await page.click("app-desktop-header div.login-wrapper.logged-in > button")
        await page.waitForSelector("div.login-details")
      })
    })
    describe("Check Basic Account Type", async() => {
      it("Login as Basic", async() => {
        await page.waitForSelector('app-login form > input:nth-child(2)')
        await page.$eval("app-login form > input:nth-child(2)", el => el.value = '')
        await page.$eval('app-login form > input:nth-child(4)', el => el.value = '')
        await page.type('app-login form > input:nth-child(2)', process.env.USERNAME)
        await page.type('app-login form > input:nth-child(4)', process.env.PASSWORD)
        await page.click('app-login form > button')
      })
      it("Goto Settings", async() => {
        await page.waitForSelector('div.desktop-nav ul > li:nth-child(6) > a')
        await page.click('div.desktop-nav ul > li:nth-child(6) > a')
        await page.waitForSelector('form > div.submit-row.text-center > button')
      })
      it("Check Account Type", async() => {
        await page.waitForSelector("app-desktop-sidebar li.member-menu-wrapper > span.member-badge.basic")
        const sidebarSubType = await page.$eval("app-desktop-sidebar li.member-menu-wrapper > span.member-badge.basic", el => el.innerText)
        await page.waitForSelector("app-settings form > div:nth-child(6) > span.icon-down-arrow-of-angle.icon")
        await page.click("app-settings form > div:nth-child(6) > span.icon-down-arrow-of-angle.icon")
        await page.waitForSelector("div.settings-subscription div:nth-child(1) > p > strong")
        const accountSubType = await page.$eval("div.settings-subscription div:nth-child(1) > p > strong", el => el.innerText)
        expect(sidebarSubType).toBe(accountSubType)
      })
    })
  })

  describe("Change Email", async() => {
    it("Enter Email In Field and Submit", async() => {
      await page.$eval('form input', e => e.value = '')
      await page.type('form input', process.env.CHANGE_EMAIL)
      await page.click('form > div.submit-row.text-center > button')
    })
    it("Check For Success Message", async() => {
      await page.waitForSelector('div.msg.msg--success')
    })
  })

  describe("Change Current Password", async() => {
    it("Type in password fields and submit", async() => {
      await page.type('input[formcontrolname="old_password"]', process.env.PASSWORD)
      await page.type('input[formcontrolname="new_password"]', process.env.PASSWORD)
      await page.type('input[formcontrolname="new_password_repeat"]', process.env.PASSWORD)
      await page.click('form > div.submit-row.text-center > button')
    })
    it("Check for success message", async() => {
      await page.waitForSelector('div.msg.msg--success')
    })
  })

  describe("Enable/Disable notification", async() => {
    it("Toggle Notification", async() => {
      await page.$$eval('.page-content-subheader', el => Array.from(el).pop().children[1].click() )
      await page.waitForSelector('input[formcontrolname="email_notifications"]')
      await page.click('input[formcontrolname="email_notifications"]')
      await page.click('form > div.submit-row.text-center > button')
    })
    it("Check for success message", async() => {
      await page.waitForSelector('div.msg.msg--success')
      await page.waitFor(3000)
    })
  })
// keep skipped
  describe.skip("Delete account", async() => {
    it("Click Delete Button", async() => {
      await page.$$eval('.page-content-subheader', el => Array.from(el)[3].children[1].click() )
      await page.waitForSelector('div.settings-delete button')
      await page.click('div.settings-delete button')
      await page.waitForSelector('app-delete div.p-4 button')
      await page.click('app-delete div.p-4 button')
      await page.waitForSelector('.delete-account-wrapper p')
    })
  })
})

// VISITOR PAGE
describe("Visitor Page", async() => {
  it("Logout", async() => {
    await page.goto(baseUrl, {waitUntil: "networkidle0"})
    await page.waitForSelector("app-desktop-header div.login-wrapper.logged-in > button")
    await page.click("app-desktop-header div.login-wrapper.logged-in > button")
    await page.waitForSelector(".login-details")
  })
  it("login as Basic User", async() => {
    await page.goto(baseUrl, {waitUntil: "networkidle0"})
    await page.click(".login-btn")
    await page.waitForSelector('.login-details > form')
    await page.type('input[formcontrolname="email_or_nick"]', process.env.USERNAME_P)
    await page.type('input[formcontrolname="password"]', process.env.PASSWORD)
    await page.click('button[type="submit"]')
    await page.waitForSelector('app-desktop-sidebar div.side-menu > ul > li:nth-child(3)')
    await page.click('app-desktop-sidebar div.side-menu > ul > li:nth-child(3)')
    await page.waitForSelector('app-member')
  })
  describe("Add to favourite", async() => {
    it(" 'Empty Heart' icon becomes 'Filled Heart' icon", async() => {
      await page.waitForSelector('app-member > div.profile-pic-wrapper span.fa.fa-heart-o')
      await page.click('app-member > div.profile-pic-wrapper span.fa.fa-heart-o')
      await page.waitForSelector('app-member > div.profile-pic-wrapper span.fa.fa-heart')
    })
    it(" 'Added to Favorites' success message appears", async() => {
      await page.waitForSelector('body > app-root > app-notification-list > div')
    })
  })
  describe("Remove From Favourite", async() => {
    it(" 'Filled Heart' icon becomes 'Empty Heart' icon", async() => {
      await page.click('app-member > div.profile-pic-wrapper span.fa.fa-heart')
      await page.waitForSelector('app-member > div.profile-pic-wrapper span.fa.fa-heart-o')
    })
    it(" 'Removed from Favorites' success message appears", async() => {
      await page.waitForSelector('body > app-root > app-notification-list > div')
    })
  })
  describe.skip("If Pagination exists", async() => {
    var favPagination
    var pageUrl
    it("Loader & Next page", async() => {
      await page.waitForSelector('div.content-container div.member-list-wrapper > div.row > app-member > div.profile-pic-wrapper > div.profile-pic')
      await page.waitForSelector('div.content-container div.member-list-wrapper > ngb-pagination > ul > li > a')
      favPagination = await page.$$eval('div.content-container div.member-list-wrapper > ngb-pagination > ul > li > a', e => e.length)
      await page.waitForFunction(() => document.querySelectorAll('div.content-container div.member-list-wrapper > ngb-pagination > ul > li > a'), e => e.length === favPagination)
      await page.click('div.content-container div.member-list-wrapper > ngb-pagination > ul > li:last-child > a');
      const pageNumber = await page.$eval('div.content-container div.member-list-wrapper > ngb-pagination > ul > li:nth-child(3).page-item.active > a', e => +e.innerText.split(' ').splice(0,1))
      expect(pageNumber).toEqual(2)
    })
    it("Loader & Prev Page", async() => {
      await page.waitForSelector('div.content-container div.member-list-wrapper > div.row > app-member > div.profile-pic-wrapper > div.profile-pic')
      await page.waitForSelector('div.content-container div.member-list-wrapper > ngb-pagination > ul > li > a')
      favPagination = await page.$$eval('div.content-container div.member-list-wrapper > ngb-pagination > ul > li > a', e => e.length)
      await page.waitForFunction(() => document.querySelectorAll('div.content-container div.member-list-wrapper > ngb-pagination > ul > li > a'), e => e.length === favPagination)
      await page.click('div.content-container div.member-list-wrapper > ngb-pagination > ul > li:first-child > a');
      const pageNumber = await page.$eval('div.content-container div.member-list-wrapper > ngb-pagination > ul > li:nth-child(2).page-item.active > a', e => +e.innerText.split(' ').splice(0,1))
      expect(pageNumber).toEqual(1)
    })
    it("Loader & Random page", async() => {
        var firstLastSliced
        var dotIndex
        var randomPage
        await page.waitForSelector('div.content-container div.member-list-wrapper > div.row > app-member > div.profile-pic-wrapper > div.profile-pic')
        var favPaginationn = await page.$$eval('div.content-container div.member-list-wrapper > ngb-pagination > ul > li > a', e => e.length)
        await page.waitForFunction(() => document.querySelectorAll('div.content-container div.member-list-wrapper > ngb-pagination > ul > li > a'), e => e.length === favPaginationn, {polling: 'mutation'})
        await page.waitForSelector('div.content-container div.member-list-wrapper > ngb-pagination > ul > li > a')
        await page.waitFor(5000)
        var random = await page.$$eval('div.content-container div.member-list-wrapper > ngb-pagination > ul > li > a', e => {
          firstLastSliced = Array.from(e)
          dotIndex = firstLastSliced.map(el => el.innerText).indexOf('...') + 1
          do {
            randomPage = Math.floor(Math.random() * firstLastSliced.length) + 1
          } while (randomPage === dotIndex || randomPage === 1 || randomPage === 2 || randomPage === firstLastSliced.length);
          return randomPage
          }
        )

      const pageNumberText = await page.$eval(`div.content-container div.member-list-wrapper > ngb-pagination > ul > li:nth-child(${random}) a`, e => e.innerText.split(' ')[0])
      await page.click(`div.content-container div.member-list-wrapper > ngb-pagination > ul > li:nth-child(${random}) a`)
      await page.waitFor(3000)
      await page.waitForSelector('app-visitor div.content-container div.member-list-wrapper > div.row > app-member:nth-child(1) > div.profile-pic-wrapper > div.profile-pic')
      let pageUrl= await page.evaluate(()=> {
        var urle=document.URL.split('=')[1];
        return urle;
      })
      expect(+pageNumberText).toEqual(+pageUrl)
    })
  })
})

// Profile Page

describe('Profile Page', async() => {
  it("Goto Profile", async() => {
    await page.waitForSelector('app-vip-members div')
    await page.click('app-vip-members div')
  })
  describe("Add to favourite", async() => {
    it(" 'Empty Heart' icon becomes 'Filled Heart' icon", async() => {
        await page.waitForSelector('app-profile div.content-container > div.profile-info > div.profile__image__wrapper > div.profile__image > img')
        await page.waitForSelector('app-profile div.profile__image__wrapper button:nth-child(2)')
        await page.click('app-profile div.profile__image__wrapper button:nth-child(2)')
        await page.waitForSelector('app-profile div.profile__image__wrapper button:nth-child(2) span.fa.fa-heart')
    })
    it(" 'Added to Favorites' success message appears", async() => {
      await page.waitForSelector('body > app-root > app-notification-list > div')
    })
  })
  describe("Remove from favourites", async() => {
    it(" 'Filled Heart' icon becomes 'Empty Heart' icon", async() => {
      await page.click('app-profile div.profile__image__wrapper button:nth-child(2)')
      await page.waitForSelector('app-profile div.profile__image__wrapper button:nth-child(2) span.fa.fa-heart-o')
    })
    it("'Removed from Favorites' success message appears", async() => {
      await page.waitForSelector('body > app-root > app-notification-list > div')
    })
  })
  describe("Photo Album", async() => {
    var i, prevImgSrc, lastImgSrc, nextImgSrc;
    it("Goto Home", async() => {
      await page.click('app-desktop-sidebar div.side-menu > ul > li:nth-child(1)')
      await page.waitForSelector('swiper')
    })
    it("check for multiple photos in album", async() => {
      for(i = 1; i < 6; i++) {
        await page.waitForSelector('.vip-member-wrapper app-vip-members > div.vip-member-list')
        const memberName = await page.$eval(`.vip-member-wrapper app-vip-members:nth-of-type(${i}) span.name`, e => e.innerText)
        await page.click(`.vip-member-wrapper app-vip-members:nth-of-type(${i}) > div`)
        await page.waitForFunction( (memberName) => document.querySelector('app-profile div.profile-info > div.profile__card > h4').innerText === memberName, {polling: 'mutation'}, memberName)
        await page.waitForSelector('.photos div.image')
        const photoCount = await page.$$eval('.photos div.image', el => el.length)
        if (photoCount > 1) {
          break;
        }
      }
    })
    it("Clicking on photo opens gallery modal", async() => {
      await page.click('.photos div.image')
      await page.waitFor('div.lightbox.animation.fadeIn > div.lb-outerContainer.transition > div > img')
    })
    it("Click > for next image", async() => {
      prevImgSrc = await page.$eval('div.lightbox.animation.fadeIn > div.lb-outerContainer.transition > div > img', el => el.getAttribute('src'))
      await page.evaluate(() => {
        document.querySelector('div.lb-nav > a.lb-next').click();
      });
      await page.waitForFunction( (prevImgSrc) => document.querySelector('div.lightbox.animation.fadeIn > div.lb-outerContainer.transition > div > img').getAttribute('src') !== prevImgSrc, {polling: 'mutation'}, prevImgSrc)
      lastImgSrc = await page.$eval('div.lightbox.animation.fadeIn > div.lb-outerContainer.transition > div > img', e => e.getAttribute('src'))
      expect(prevImgSrc).not.toBe(lastImgSrc)
    })
    it("Click < for previous image", async() => {
      await page.evaluate(() => {
        document.querySelector('div.lb-nav > a.lb-prev').click();
      });
      await page.waitForFunction( (lastImgSrc) => document.querySelector('div.lightbox.animation.fadeIn > div.lb-outerContainer.transition > div > img').getAttribute('src') !== lastImgSrc, {polling: 'mutation'}, lastImgSrc)
      nexImgSrc = await page.$eval('div.lightbox.animation.fadeIn > div.lb-outerContainer.transition > div > img', e => e.getAttribute('src'))
      expect(prevImgSrc).toBe(nexImgSrc)
    })
  })
})

// ADVANCED SEARCH PAGE

describe("Advanced Search Page", async() => {
  it("Goto Advanced Search Page", async() => {
    await page.reload({ waitUntil: 'networkidle0' })
    await page.waitForSelector('app-desktop-sidebar div.side-menu > ul > li:nth-child(4)')
    await page.click('app-desktop-sidebar div.side-menu > ul > li:nth-child(4)')
    await page.waitForFunction( () => Array.from(document.querySelectorAll('div.card-block')).length === 4 , {polling: 'mutation'} )
  })
  it("Select random values from General Section", async() => {
    selectArr = await page.$$eval('#config-panel-one select',
                      els => Array.from(els).map(e => 'select[formcontrolname=' + '\"' + e.getAttribute('formcontrolname') + '\"' + ']'));
    await page.selectRandom(selectArr, { multiple: true })
  })
  it("Select random values from Open To Section", async() => {
    checkArr = await page.$$eval('#preventchange-2 input',
                      els => Array.from(els).map(e => 'input[id=' + '\"' + e.getAttribute('id') + '\"' + ']'));
    await page.checkRandom(checkArr)
  })
  it("Select random values from Preferences", async() => {
    checkArr = await page.$$eval('#preventchange-3 input',
                      els => Array.from(els).map(e => 'input[id=' + '\"' + e.getAttribute('id') + '\"' + ']'));
    await page.checkRandom(checkArr)
  })
  it("Select random values from Character", async() => {
    checkArr = await page.$$eval('#preventchange-4 input',
                      els => Array.from(els).map(e => 'input[id=' + '\"' + e.getAttribute('id') + '\"' + ']'));
    await page.checkRandom(checkArr)
  })
  it("Click on advanced search button", async() => {
    await page.click('app-search form > div > button')
  })
  it("Check for search result", async() => {
    await page.waitForSelector('app-search-result div.content-container div.member-list-wrapper')
  })
  describe("Accordian Test", async() => {
    it("Go back to advanced search page", async() => {
      await page.waitForSelector('app-desktop-sidebar div.side-menu > ul > li:nth-child(4)')
      await page.click('app-desktop-sidebar div.side-menu > ul > li:nth-child(4)')
      await page.waitForFunction( () => Array.from(document.querySelectorAll('div.card-block')).length === 4 , {polling: 'mutation'} )
    })
    it("Check for General Section Body", async() => {
      await page.waitForSelector("#config-panel-one-header + div.card-block")
    })
    it("Check for accordian collapse", async() => {
      await page.click("#config-panel-one-header > a")
      const isExist = await page.evaluate(() => {
        const e = document.querySelector('#config-panel-one-header + div.card-block');
        if (!e)
          return false;
        else 
          return true;
      });
      expect(isExist).toBeFalsy()
    })
    it("Check for accordian expand", async() => {
      await page.waitFor(500)
      await page.click("#config-panel-one-header > a")
      await page.waitForSelector("#config-panel-one-header + div.card-block")
    })
  })
})

// ADD PHOTOS PAGE

describe("Add Photos Page", async() => {
  // it('logout', async() => {
  //   await page.waitForSelector('app-desktop-header > div > div.container > div.login-wrapper.logged-in > button')
  // })
  // // it("login as Basic User", async() => { 
  //   it('1', async() => {
  //     await page.reload({ waitUntil: 'networkidle0' })
  //   })
  //   it('2', async() => {
  //     await page.waitForSelector('app-login form > input:nth-child(2)')
  //   })
  //   it('3', async() => {
  //     await page.type('app-login form > input:nth-child(2)', process.env.USERNAME)
  //   })
  //   it('4', async() => {
  //     await page.type('app-login form > input:nth-child(4)', process.env.PASSWORD)
  //   })
  //   it('5', async() => {
  //     await page.click('app-login form > button')
  //   })
  // })
  it("Login as basic", async() => {
    await page.goto(baseUrl, {waitUntil: "networkidle0"})
    await page.click(".login-btn")
    await page.waitForSelector('.login-details > form')
    await page.type('input[formcontrolname="email_or_nick"]', process.env.USERNAME_P)
    await page.type('input[formcontrolname="password"]', process.env.PASSWORD)
    await page.click('button[type="submit"]')
  })
  it("Goto Add Photos Page", async() => {
    await page.waitForSelector("app-desktop-header div.desktop-nav ul > li:nth-child(2) > a")
    await page.click("app-desktop-header div.desktop-nav ul > li:nth-child(2) > a")
    await page.waitForSelector("app-profile-pic div.content-container > div.row.profile-pic-list.album-pics-wrapper > div > div > button")
  })
  describe('Profile image', async() => {
    it('Add profile image', async() => {
      await page.waitForSelector('app-profile-pic div.content-container > div.row.profile-pic-list.display-pic-wrapper > div.col-6.col-xsm-3.upload-button-wrapper > div > span > input[type="file"]')
      const profilePicUpload = await page.$('app-profile-pic div.content-container > div.row.profile-pic-list.display-pic-wrapper > div.col-6.col-xsm-3.upload-button-wrapper > div > span > input[type="file"]')
      await profilePicUpload.uploadFile('./__tests__/profile-pics/profile-pic1.jpg')
      await page.waitForSelector('ngb-modal-window > div > div > app-popup-upload-info > div > div > button')
      await page.click('ngb-modal-window > div > div > app-popup-upload-info > div > div > button')
    })
    it('Remove profile image', async() => {
      await page.waitForSelector('app-profile-pic div.content-container > div.row.profile-pic-list.display-pic-wrapper > div.col-6.col-xsm-3.upload-button-wrapper > div > app-pic-card > div > span')
      await page.click('app-profile-pic div.content-container > div.row.profile-pic-list.display-pic-wrapper > div.col-6.col-xsm-3.upload-button-wrapper > div > app-pic-card > div > span')
      await page.waitForSelector('ngb-modal-window > div > div > app-image-delete-confirm > div > div > div > div:nth-child(2) > button')
      await page.click('ngb-modal-window > div > div > app-image-delete-confirm > div > div > div > div:nth-child(2) > button')
    })
  })
  describe('Album image', async() => {
    var deleteNodeLengh, randomDelete
    it('Add single image', async() => {
      await page.waitForSelector('app-profile-pic div.content-container > div.row.profile-pic-list.album-pics-wrapper > div > span > input[type="file"]')
      const elementHandle = await page.$('app-profile-pic div.content-container > div.row.profile-pic-list.album-pics-wrapper > div > span > input[type="file"]')
      await elementHandle.uploadFile('./__tests__/profile-pics/profile-pic.jpg')
      await page.waitForSelector('app-profile-pic div.content-container > div.row.profile-pic-list.album-pics-wrapper > div:nth-child(1) > app-pic-card > div > img')
    })
    it('Add multiple images', async() => {
      const elementHandle = await page.$('app-profile-pic div.content-container > div.row.profile-pic-list.album-pics-wrapper > div > span > input[type="file"]')
      await elementHandle.uploadFile('./__tests__/profile-pics/profile-pic1.jpg', './__tests__/profile-pics/profile-pic2.jpg')
      await page.waitForSelector('app-profile-pic div.content-container > div.row.profile-pic-list.album-pics-wrapper > div:nth-child(3) > app-pic-card > div > img')
    })
    // it('Delete single image', async() => {
      it('1', async() => {
        deleteNodeLengh = await page.$$eval('app-profile-pic div.content-container > div.row.profile-pic-list.album-pics-wrapper > div.col-6 > app-pic-card > div > span.profile-pic--delete', e => e.length)
      })
      it('2', async() => {
        randomDelete = Math.floor(Math.random() * deleteNodeLengh) + 1
        console.log(randomDelete)
      })      
      it('3', async() => {
        await page.click(`app-profile-pic div.content-container > div.row.profile-pic-list.album-pics-wrapper > div.col-6:nth-child(${randomDelete}) > app-pic-card > div > span.profile-pic--delete`)
      })      
      it('4', async() => {
        await page.waitForSelector('ngb-modal-window > div > div > app-image-delete-confirm > div > div > div > div:nth-child(2) > button')
      })      
      it('5', async() => {
        await page.click('ngb-modal-window > div > div > app-image-delete-confirm > div > div > div > div:nth-child(2) > button')
      })      
      it('6', async() => {
        await page.waitFor(3000)
        await page.waitForSelector(`app-profile-pic div.content-container > div.row.profile-pic-list.album-pics-wrapper > div.col-6:nth-child(${randomDelete}) > app-pic-card > div > img`, {visible: false})
        await page.waitFor(3000)
      })
    // })
  })
})

// ViKaS NeW

// Favorites page 
describe("Favorites page", async () => {
  describe("pagination does not exists", async () => {
    it('logout', async() => {
      await page.click('app-desktop-header > div > div.container > div.login-wrapper.logged-in > button')
    })
    it("login as debtest", async () => {
      // await page.goto(baseUrl, { waitUntil: "networkidle0" })
      // await page.click('.login-btn')
      await page.waitForSelector('input[formcontrolname="email_or_nick"]')
      await page.type('input[formcontrolname="email_or_nick"]', process.env.LOGEMAIL)
      await page.type('input[formcontrolname="password"]', process.env.PASSWORD)
      await page.click('button[type="submit"]')
    })
    it("Initial setup", async () => {
      await page.waitForSelector('app-desktop-header div.desktop-nav ul > li:nth-child(1) > a')
      await page.click('app-desktop-header div.desktop-nav ul > li:nth-child(1) > a')

      //click on favourite tab
      await page.waitForSelector('app-desktop-header div.desktop-nav ul > li:nth-child(4) > a')
      await page.click('app-desktop-header div.desktop-nav ul > li:nth-child(4) > a')
    })
    it("pagination does not exists", async () => {
      await page.waitForSelector('div.content-container .no-favs .no-profile-result')
      singleMember = await page.waitForSelector('div.member-list-wrapper > div.row > app-member-list', { hidden: true })
    })
  })
  describe("pagination exists", async () => {
  var randomFav
  var favLength
  it('logout', async() => {
    await page.click('app-desktop-header > div > div.container > div.login-wrapper.logged-in > button')
    // await page.waitForSelector('input[formcontrolname="email_or_nick"]')
  })
    it("login as elite", async () => {
      // await page.goto(baseUrl, { waitUntil: "networkidle0" })
      // await page.click('.login-btn')
      await page.waitForSelector('input[formcontrolname="email_or_nick"]')
      await page.type('input[formcontrolname="email_or_nick"]', process.env.ELITUSER)
      await page.type('input[formcontrolname="password"]', process.env.PASSWORD)
      await page.click('button[type="submit"]')
    })
    it("Initial setup", async () => {
      await page.waitForSelector('app-desktop-header div.desktop-nav ul > li:nth-child(1) > a')
      await page.click('app-desktop-header div.desktop-nav ul > li:nth-child(1) > a')
      await page.waitForSelector('app-desktop-header div.desktop-nav ul > li:nth-child(4) > a')
      await page.click('app-desktop-header div.desktop-nav ul > li:nth-child(4) > a')
      favLength = await page.$$eval('div.content-container div.member-list-wrapper > div.row > app-member-list', e => e.length)
      await page.waitForFunction(() => document.querySelectorAll('div.content-container div.member-list-wrapper > div.row > app-member-list'), e => e.length === favLength)
      randomFav = await page.$$eval('div.content-container div.member-list-wrapper > div.row > app-member-list',
        e => Math.floor(Math.random() * e.length))
    })
    it("favourites profiles exists", async () => {
      await page.waitForSelector('div.content-container .no-favs .no-profile-result', { hidden: true })
    })
    describe("goto different pages", async() => {
      var favPagination
      var pageUrl
      it("goto next page", async() => {
        await page.waitForSelector('div.member-list-wrapper > div.row > app-member-list > div > div.member-image-wrapper > div')
        await page.waitForSelector('div.member-list-wrapper > ngb-pagination > ul > li a')
        favPagination = await page.$$eval('div.member-list-wrapper > ngb-pagination > ul > li a', e => e.length)
        await page.waitForFunction(() => document.querySelectorAll('div.member-list-wrapper > ngb-pagination > ul > li a'), e => e.length === favPagination)
        await page.click('div.member-list-wrapper > ngb-pagination > ul > li:last-child > a');
        const pageNumber = await page.$eval('div.member-list-wrapper > ngb-pagination > ul > li:nth-child(3).page-item.active > a', e => +e.innerText.split(' ').splice(0,1))
        expect(pageNumber).toEqual(2)
      })
      it("goto previous page", async() => {
        await page.waitForSelector('div.member-list-wrapper > div.row > app-member-list > div > div.member-image-wrapper > div')
        await page.waitForSelector('div.member-list-wrapper > ngb-pagination > ul > li a')
        favPagination = await page.$$eval('div.member-list-wrapper > ngb-pagination > ul > li a', e => e.length)
        await page.waitForFunction(() => document.querySelectorAll('div.member-list-wrapper > ngb-pagination > ul > li a'), e => e.length === favPagination)
        await page.click('div.member-list-wrapper > ngb-pagination > ul > li:first-child > a');
        const pageNumber = await page.$eval('div.member-list-wrapper > ngb-pagination > ul > li:nth-child(2).page-item.active > a', e => +e.innerText.split(' ').splice(0,1))
        expect(pageNumber).toEqual(1)
      })
      it("goto random page", async() => {
          var firstLastSliced
          var dotIndex
          var randomPage
          await page.waitForSelector('div.member-list-wrapper > div.row > app-member-list > div > div.member-image-wrapper > div')
          var favPaginationn = await page.$$eval('div.member-list-wrapper > ngb-pagination > ul > li a', e => e.length)
          await page.waitForFunction(() => document.querySelectorAll('div.member-list-wrapper > ngb-pagination > ul > li a'), e => e.length === favPaginationn, {polling: 'mutation'})
          await page.waitForSelector('div.content-container > div > div.member-list-wrapper > ngb-pagination > ul > li > a')
          await page.waitFor(5000)
          var random = await page.$$eval('div.content-container > div > div.member-list-wrapper > ngb-pagination > ul > li > a', e => {
            firstLastSliced = Array.from(e)
            dotIndex = firstLastSliced.map(el => el.innerText).indexOf('...') + 1
            do {
              randomPage = Math.floor(Math.random() * firstLastSliced.length) + 1
            } while (randomPage === dotIndex || randomPage === 1 || randomPage === 2 || randomPage === firstLastSliced.length);
            return randomPage
            }
          )

        const pageNumberText = await page.$eval(`div.member-list-wrapper > ngb-pagination > ul > li:nth-child(${random}) a`, e => e.innerText.split(' ')[0])
        await page.click(`div.member-list-wrapper > ngb-pagination > ul > li:nth-child(${random}) a`)
        await page.waitFor(3000)
        await page.waitForSelector('app-favorite > app-favorite-my div.content-container div.member-list-wrapper > div.row > app-member-list:nth-child(1) > div > div.member-image-wrapper > div')
        let pageUrl= await page.evaluate(()=> {
          var urle=document.URL.split('=')[1];
          return urle;
        })
        expect(+pageNumberText).toEqual(+pageUrl)
      })
    })
    describe("Delete profile", async () => {
      it("Delete random profile from list", async () => {
        await page.waitForSelector('div.content-container div.member-list-wrapper > div.row > app-member-list > div > div.member-info .close-btn')
        var closeLength = await page.$$eval('div.content-container div.member-list-wrapper > div.row > app-member-list > div > div.member-info .close-btn', e => e.length)
        await page.waitForFunction(() => document.querySelectorAll('div.content-container div.member-list-wrapper > div.row > app-member-list > div > div.member-info .close-btn'), e => e.length === closeLength)
        var randomClose = await page.$$eval('div.content-container div.member-list-wrapper > div.row > app-member-list > div > div.member-info .close-btn', e => Math.floor(Math.random() * e.length))
        await page.click(`div.content-container div.member-list-wrapper > div.row > app-member-list:nth-of-type(${randomClose + 1}) > div > div.member-info .close-btn`)
      })
      it("Check if deleted", async () => {
        await page.waitForSelector('app-notification-list .msg--success')
      })
      it("logout", async() => {
        await page.waitForSelector('app-desktop-header div.container > div.login-wrapper.logged-in > button')
        await page.click('app-desktop-header div.container > div.login-wrapper.logged-in > button')
        await page.waitForSelector('div.login-details > form')
      })
    })
  })
})

// EDIT PAGE
// todo
describe("Edit Profile page", async() => {
  it('login as basic and goto edit page', async() => {
    await page.goto(baseUrl, { waitUntil: "networkidle0" })
    await page.click('.login-btn')
    await page.waitForSelector('input[formcontrolname="email_or_nick"]')
    await page.type('input[formcontrolname="email_or_nick"]', process.env.COMPMAIL)
    await page.type('input[formcontrolname="password"]', process.env.PASSWORD)
    await page.click('button[type="submit"]')
    await page.waitForSelector('app-desktop-header div.desktop-nav > div > div > ul > li:nth-child(1) > a')
    await page.click('app-desktop-header div.desktop-nav > div > div > ul > li:nth-child(1) > a')
    await page.waitForFunction(() => document.querySelectorAll('.content-container ngb-accordion .card .card-header').length === 5, {polling: 'mutation'})
  })
  describe("Error checks", async() => {
    it("Empty name error", async() => {
      await page.$eval('div.content-container > div.form-container > form > div.row > div:nth-child(1) > input', e => e.value = '')
      await page.type('div.content-container > div.form-container > form > div.row > div:nth-child(1) > input', 'a')
      await page.keyboard.down('Backspace')
      await page.waitForSelector('div.content-container > div.form-container > form > div.row > div:nth-child(1) > input + .msg--error')
    })
    it("----------------------------- city error", async() => {
      await page.click('div.content-container > div.form-container > form > div.row > div:nth-child(6) > p-dropdown')
      await page.waitForSelector('div.form-container > form > div.row > div:nth-child(6) > p-dropdown > div > div.ui-dropdown-panel.ui-widget-content > div.ui-dropdown-items-wrapper > ul > li:nth-child(1) > span')
      await page.waitForSelector('div.form-container > form > div.row p-dropdown div.ui-dropdown-panel.ui-widget-content > div.ui-dropdown-items-wrapper > ul > li:nth-child(11) > span')
      await page.click('div.form-container > form > div.row p-dropdown div.ui-dropdown-panel.ui-widget-content > div.ui-dropdown-items-wrapper > ul > li:nth-child(11) > span')
      await page.waitForSelector('div.form-container > form > div.row p-dropdown + .msg--error')
    })
  })
  describe("Accordian", async() => {
    var randomAccord
    it('initial setup', async() => {
      await page.reload({ waitUntil: "networkidle0" })
    })
    
    it('loop through second to last accordian(check content, open, close and check content)', async() => {
      for(i=3; i<7; i++) {
        await page.waitForSelector(`.content-container ngb-accordion .card .card-header:nth-child(${i}) a`)
        await page.click(`.content-container ngb-accordion .card .card-header:nth-child(${i}) a`)
        await page.waitForSelector(`.content-container ngb-accordion .card .card-block:nth-child(${i+1})`)
        await page.click(`.content-container ngb-accordion .card .card-header:nth-child(${i}) a`)
        await page.waitForSelector(`.content-container ngb-accordion .card .card-block:nth-child(${i+1})`, {hidden: true})
      }
    })
    it('open first accordian and check for content', async() => {
      await page.click('.content-container ngb-accordion .card .card-header:nth-child(1) a')
      await page.waitForSelector('.content-container ngb-accordion .card .card-block:nth-child(2)', {hidden: true})
    })
    it('close first accordian check for content', async() => {
      await page.click('.content-container ngb-accordion .card .card-header:nth-child(1) a')
      await page.waitForSelector('.content-container ngb-accordion .card .card-block:nth-child(2)')
    })
  })  
  describe("Editing profile and saving", async() => {
    it('random changes in name section', async() => {
      await page.reload({ waitUntil: "networkidle0" })
      await page.waitForSelector('div.content-container > div.form-container > form > div.row > div:nth-child(1) > input')
      let selectBoxesSelectors = [
        'app-edit-profile form select[formcontrolname="marital_status_id"]',
        'app-edit-profile form select[formcontrolname="day"]',
        'app-edit-profile form select[formcontrolname="month"]',
        'app-edit-profile form select[formcontrolname="year"]',
        'app-edit-profile form select[formcontrolname="province_id"]'
      ]
      await page.selectRandom(selectBoxesSelectors, { multiple: true })
      await page.click('div.content-container > div.form-container > form > div.row > div:nth-child(6) > p-dropdown')
      await page.waitForSelector('div.form-container > form > div.row > div:nth-child(6) > p-dropdown > div > div.ui-dropdown-panel.ui-widget-content > div.ui-dropdown-items-wrapper > ul > li:nth-child(1) > span')
      var random = await page.$$eval('app-edit-profile div.content-container > div.form-container > form > div.row p-dropdown > div > div.ui-dropdown-panel.ui-widget-content > div.ui-dropdown-items-wrapper > ul > li > span', e => {
        var arr = Array.from(e)
        var dotIndex = arr.map(el => el.innerText).indexOf('------------------------------------------') + 1
        do {
          var randomOption = Math.floor(Math.random() * arr.length) + 1
        } while (randomOption === dotIndex);
        return randomOption
        }
      )
      await page.click(`div.form-container > form > div.row p-dropdown div.ui-dropdown-panel.ui-widget-content > div.ui-dropdown-items-wrapper > ul > li:nth-child(${random}) > span`)
    })
    it("random change in general section", async() => {
      let selectBoxesSelectors = [
        '#config-panel-one select[formcontrolname="sex"]',
        '#config-panel-one select[formcontrolname="seeking"]',
        '#config-panel-one select[formcontrolname="hair_color_id"]',
        '#config-panel-one select[formcontrolname="eye_color_id"]',
        '#config-panel-one select[formcontrolname="body_type_id"]', 
        '#config-panel-one select[formcontrolname="height"]',
        '#config-panel-one select[formcontrolname="weight"]',
        '#config-panel-one select[formcontrolname="smoke_id"]'
      ]
      await page.selectRandom(selectBoxesSelectors, { multiple: true })
    })
    it("random change in open to section", async() => {
      await page.click('.form-container ngb-accordion .card #preventchange-2-header > a')
      // await page.waitFor(3000)
      let selectCheck = [
        '#preventchange-2 > app-checkbox-group > div:nth-child(1) > div > label.form-check-label.actual',
        '#preventchange-2 > app-checkbox-group > div:nth-child(2) > div > label.form-check-label.actual',
        '#preventchange-2 > app-checkbox-group > div:nth-child(3) > div > label.form-check-label.actual',
        '#preventchange-2 > app-checkbox-group > div:nth-child(4) > div > label.form-check-label.actual',
        '#preventchange-2 > app-checkbox-group > div:nth-child(5) > div > label.form-check-label.actual',
        '#preventchange-2 > app-checkbox-group > div:nth-child(6) > div > label.form-check-label.actual',
        '#preventchange-2 > app-checkbox-group > div:nth-child(7) > div > label.form-check-label.actual',
        '#preventchange-2 > app-checkbox-group > div:nth-child(8) > div > label.form-check-label.actual',
        '#preventchange-2 > app-checkbox-group > div:nth-child(9) > div > label.form-check-label.actual',
        '#preventchange-2 > app-checkbox-group > div:nth-child(10) > div > label.form-check-label.actual',
        '#preventchange-2 > app-checkbox-group > div:nth-child(11) > div > label.form-check-label.actual',
        '#preventchange-2 > app-checkbox-group > div:nth-child(12) > div > label.form-check-label.actual',
      ]
      await page.checkRandom(selectCheck)
    })
    it("random check in prefrences section", async() => {
      await page.click('.form-container ngb-accordion .card #preventchange-3-header > a')
      let selectCheck = [
        '#preventchange-3 > app-checkbox-group > div:nth-child(1) > div > label.form-check-label.actual',
        '#preventchange-3 > app-checkbox-group > div:nth-child(2) > div > label.form-check-label.actual',
        '#preventchange-3 > app-checkbox-group > div:nth-child(3) > div > label.form-check-label.actual',
        '#preventchange-3 > app-checkbox-group > div:nth-child(4) > div > label.form-check-label.actual',
        '#preventchange-3 > app-checkbox-group > div:nth-child(5) > div > label.form-check-label.actual',
        '#preventchange-3 > app-checkbox-group > div:nth-child(6) > div > label.form-check-label.actual',
        '#preventchange-3 > app-checkbox-group > div:nth-child(7) > div > label.form-check-label.actual',
        '#preventchange-3 > app-checkbox-group > div:nth-child(8) > div > label.form-check-label.actual',
        '#preventchange-3 > app-checkbox-group > div:nth-child(9) > div > label.form-check-label.actual',
        '#preventchange-3 > app-checkbox-group > div:nth-child(10) > div > label.form-check-label.actual',
        '#preventchange-3 > app-checkbox-group > div:nth-child(11) > div > label.form-check-label.actual',
        '#preventchange-3 > app-checkbox-group > div:nth-child(12) > div > label.form-check-label.actual',
      ]
      await page.checkRandom(selectCheck)
    })
    it("random check in character section", async() => {
      await page.click('#preventchange-4-header > a')
      let selectCheck = [
        '#preventchange-4 > app-checkbox-group > div:nth-child(1) > div > label.form-check-label.actual',
        '#preventchange-4 > app-checkbox-group > div:nth-child(2) > div > label.form-check-label.actual',
        '#preventchange-4 > app-checkbox-group > div:nth-child(3) > div > label.form-check-label.actual',
        '#preventchange-4 > app-checkbox-group > div:nth-child(4) > div > label.form-check-label.actual',
        '#preventchange-4 > app-checkbox-group > div:nth-child(5) > div > label.form-check-label.actual',
        '#preventchange-4 > app-checkbox-group > div:nth-child(6) > div > label.form-check-label.actual',
        '#preventchange-4 > app-checkbox-group > div:nth-child(7) > div > label.form-check-label.actual',
        '#preventchange-4 > app-checkbox-group > div:nth-child(8) > div > label.form-check-label.actual',
        '#preventchange-4 > app-checkbox-group > div:nth-child(9) > div > label.form-check-label.actual',
        '#preventchange-4 > app-checkbox-group > div:nth-child(10) > div > label.form-check-label.actual',
        '#preventchange-4 > app-checkbox-group > div:nth-child(11) > div > label.form-check-label.actual',
        '#preventchange-4 > app-checkbox-group > div:nth-child(12) > div > label.form-check-label.actual',
      ]
      await page.checkRandom(selectCheck)
    })
    describe("'Describe yourself' 500 letters limitation", async () => {
      it('can type less than 500 characters', async () => {
        // await page.reload({ waitUntil: "networkidle0" })
        await page.click('ngb-accordion #preventchange-5-header > a')
        await page.waitForSelector('#preventchange-5 > textarea')
        await page.$eval('#preventchange-5 > textarea', e => e.value = '')
        await page.type('#preventchange-5 > textarea', message)
        await page.waitFor(3000)
        const textLength = await page.$eval('#preventchange-5 > textarea', e => e.textLength) // 7
        const remaining = await page.$eval('#preventchange-5 > p > span', e => +e.innerText.split(' ')[0]) //493
        expect(500 - textLength).toEqual(remaining)
      })
      it("cant type only 500 characters", async () => {
        await page.type('#preventchange-5 > textarea', paras)
        await page.waitFor(3000)
        const textLength = await page.$eval('#preventchange-5 > textarea', e => e.textLength)
        const zero = await page.$eval('#preventchange-5 > p > span', e => e.innerText.split(' ')[0])
        expect(500 - textLength).toEqual(+zero)
      })
    })
    it("saving profile", async() => {
      await page.click('app-edit-profile div.form-container > form .save-btn-row > button')
      await page.waitForSelector('app-edit-profile div.content-container > div.ma-25.ma-top-25 > div')
    })
  })
})

以上是关于javascript 性感日期桌面测试用例无头模式全部通过的主要内容,如果未能解决你的问题,请参考以下文章

javascript 最终性感日期测试文件

javascript 性感日期测试代码

javascript 性感日期测试片段

在无头模式下针对 webkit 渲染引擎测试页面

在无头模式下使用 Openoffice“导出”选项而不是“另存为”选项

Nightwatch测试在Headless chrome模式下找不到元素