我有一个包含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);
});
实际:我的代码在第一个测试用例运行后关闭了会话,我希望不会发生这种情况。