Сессия закрыта после первого теста в рамках теста кукольник-шут - PullRequest
0 голосов
/ 07 ноября 2019

У меня есть набор тестов, включающий 4 теста, и я хочу его запустить. Но после прохождения первого теста все остальные тестовые примеры не запускаются, и я вижу в консоли

(node:53211) UnhandledPromiseRejectionWarning: Error: Text not found ".nav-menu li:nth-child(4) b"
Protocol error (Runtime.callFunctionOn): Target closed.

Я попытался запустить его в разных файлах js, и все нормально. Но это не то, что мне нужно.

Это мой набор тестов:

import LoginPage from './pages/login-page';
import HomePage from './pages/home-page';
import AddCompaniesByNamePopup from './pages/add-companies-by-name-popup';
import ListOfCompaniesPage from './pages/list-of-companies-page'
import CompanyPage from './pages/company/company-page';
import OverviewTab from './pages/company/overview-tab';
import PleaseSubmitFeedbackPopup from './pages/company/please-submit-feedback-popup';
import companies from './utils/companiesInformation';
import * as service from './utils/randomService';
const HOME_PAGE_RELATIVE_PATH = '';
const GLOBAL_TIMEOUT = 120000; //2 Minutes

describe('Basic Company Page Context Tests:', () => {
    let page;
    let loginPage;
    let homePage;
    let addCompaniesByNamePopup;
    let listOfCompaniesPage;
    let companyPage;
    let overviewTab;
    let pleaseSubmitFeedbackPopup;
    let randomNumber = service.randomNumberDefault();
    const dashboardPath = `${process.env[`BASE_PATH_${process.env.PROD_ENV}`]}${HOME_PAGE_RELATIVE_PATH}`;

  beforeAll(async () => {
        page = await browser.newPage();
        page.setViewport({
          width: 1920,
          height: 1024,
        })
        loginPage = new LoginPage(page);
        await loginPage.openLoginPage();
        await loginPage.happyLoginFlow();
    }, GLOBAL_TIMEOUT);

    it(`The "Overview" tab appearance from the list`, async () => {
        homePage = new HomePage(page);
        await homePage.goto(dashboardPath);
        await homePage.pageIsDisplayed(dashboardPath);
        await homePage.clickSearchByCompanyName();

        addCompaniesByNamePopup = new AddCompaniesByNamePopup(page);
        await addCompaniesByNamePopup.fillCompanyName(companies.centurylink.link);
        await addCompaniesByNamePopup.clickNextButton();
        await addCompaniesByNamePopup.fillNewListName(`Autotest-${randomNumber}`);
        await addCompaniesByNamePopup.clickSaveButton();
        await addCompaniesByNamePopup.clickViewListButton();

        listOfCompaniesPage = new ListOfCompaniesPage(page);
        await listOfCompaniesPage.clickToTheCompany(companies.centurylink.name);

        companyPage = new CompanyPage(page);
        await companyPage.isOverviewTabPresent();
        await companyPage.isPeopleTabPresent();
        await companyPage.isSocialTabPresent();
        await companyPage.isFinanceTabPresent();
        await companyPage.isLeaseabPresent();
    }, GLOBAL_TIMEOUT);

    it(`Open the company page from search in header`, async () => {
        homePage = new HomePage(page);
        await homePage.goto(dashboardPath);
        await homePage.pageIsDisplayed(dashboardPath);
        await homePage.searchCompanyInHeader(companies.payoneer.name);

        companyPage = new CompanyPage(page);
        await companyPage.isOverviewTabPresent();
        await companyPage.isPeopleTabPresent();
        await companyPage.isSocialTabPresent();
        await companyPage.isFinanceTabPresent();
        await companyPage.isLeaseabPresent();
     }, GLOBAL_TIMEOUT);

    it(`The "Overview" tab appearance`, async () => {
        homePage = new HomePage(page);
        await homePage.goto(dashboardPath);
        await homePage.pageIsDisplayed(dashboardPath);
        await homePage.clickSearchByCompanyName();

        overviewTab = new OverviewTab(page);
        await overviewTab.isAboutPresent();
        await overviewTab.isIndustryPresent();
        await overviewTab.isFoundedPresent();
        await overviewTab.isHeadquarterPresent();
        await overviewTab.isContactDetailsPresent();
        await overviewTab.isSaleforcePresent();
        await overviewTab.isSocialLinkPresent(new Boolean(true));
        await overviewTab.isCompanyUrlPresent();
        await overviewTab.isLastUpdatePresent();
        await overviewTab.isLetUsKnowPresent();
        await overviewTab.isIndustryContainText(companies.payoneer.industry);
        await overviewTab.isFoundedContainText(companies.payoneer.founded);
        await overviewTab.isHeadquarterContainText(companies.payoneer.headquarters);
        await overviewTab.isContactDetailsContainText(companies.payoneer.contactDetails);
        await overviewTab.isEstimatedHeadcountePresent();
        await overviewTab.isFiltersClickable();
     }, GLOBAL_TIMEOUT);

     it(`The "Overview" tab appearance if there is no information about company`, async () => {
        homePage = new HomePage(page);
        await homePage.goto(dashboardPath);
        await homePage.pageIsDisplayed(dashboardPath);
        await homePage.searchCompanyInHeader(companies.acsisupport.name);

        overviewTab = new OverviewTab(page);
        await overviewTab.isAboutPresent();
        await overviewTab.isIndustryPresent();
        await overviewTab.isFoundedPresent();
        await overviewTab.isHeadquarterPresent();
        await overviewTab.isContactDetailsPresent();
        await overviewTab.isSaleforcePresent();
        await overviewTab.isSocialLinkPresent(new Boolean(true));
        await overviewTab.isCompanyUrlPresent();
        await overviewTab.isLastUpdatePresent();
        await overviewTab.isLetUsKnowPresent();

        await overviewTab.isIndustryContainText(companies.acsisupport.industry);
        await overviewTab.isFoundedContainText(companies.acsisupport.founded);
        await overviewTab.isHeadquarterContainText(companies.acsisupport.headquarters);
        await overviewTab.isContactDetailsContainText(companies.acsisupport.contactDetails);
        await overviewTab.isEstimatedHeadcountePresent();
        await overviewTab.isFiltersClickable();
     }, GLOBAL_TIMEOUT);
   });

Факт: мой код закрыл сеансы после первого запуска тестового примера, и я ожидал, что этого не происходит.

...