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');
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();
// 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.type('form input', 'testing123@test.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.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('.btn-green')
await page.waitForSelector('div.register-step-three-container')
})
it("third step", async() => {
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.click('.btn-green')
await page.waitForSelector('div.register .img-wrapper img.tick')
})
it("Check that it has the correct email", async() => {
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')
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.waitForSelector('button[type="submit"]')
await page.click('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("First time registered-user login", async() => {
it("Logged in", async() => {
await page.reload({waitUntil: "networkidle0"})
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.skip("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.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('.subscription-block h5 > span')
})
it("Check for User Type (at top right section of header)", async() => {
var vipText = await page.$eval('.subscription-block h5 > span', e => e.innerText)
expect(vipText).toEqual(expect.stringContaining('VIP'))
})
it("check smiley as per user type", async() => {
await page.waitForSelector('div.login-wrapper.logged-in .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', e => e.selectedOptions[0].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(500)
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(500)
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.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.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", 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})
})
})
// 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-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() => {
var closeRandomAccord = await page.$$eval('app-contact app-accordion',
e => Math.floor(Math.random() * e.length)
)
await page.waitForSelector(`app-contact app-accordion:nth-of-type(${+closeRandomAccord + 1}) .accordion--arrow .icon-down-arrow-of-angle`)
await page.click(`app-contact app-accordion:nth-of-type(${+closeRandomAccord + 1}) .accordion--title`)
await page.waitForSelector(`app-contact app-accordion:nth-of-type(${+closeRandomAccord + 1}) .accordion--arrow .icon-up-arrow-angle`)
await page.waitForSelector(`app-contact app-accordion:nth-of-type(${+closeRandomAccord + 1}) .accordion--content`)
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.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
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("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() => {
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.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)
})
})
describe.skip("Delete multiple messages", async() => {
it("Selected messages are deleted", async() => {
})
it(" 'Selected messages' number (at the top-right button 'Delete Selected') decreases by 'total selected message number'", async() => {
})
})
})
})
// 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"]')
})
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("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("Elite User", async() => {
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.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("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", 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)
})
})
})
})
以上是关于javascript 最终性感日期测试文件的主要内容,如果未能解决你的问题,请参考以下文章
❤️响应式性感美女模特博客网站模板❤️(HTML+CSS+JavaScript-前端大作业)