错误:在beforeEach和afterEach

时间:2019-12-03 14:00:03

标签: javascript selenium selenium-webdriver selenium-chromedriver mocha

您好,我正在尝试运行测试用例以打开Goog​​le页面,然后单击搜索 下面是测试用例中的代码,当我尝试执行测试用例时。屏幕快照已附着,我正面临错误

const { describe, it, beforeEach, afterEach } = require('mocha');
const Page = require('../lib/homePage');

const chai = require('chai');
const expect = chai.expect;
const chaiAsPromised = require('chai-as-promised');

chai.use(chaiAsPromised);

process.on('unhandledRejection', () => {});

(async function example() {
    try {
        describe('Google search automated testing', async function() {
            this.timeout(50000);
            let driver, page;

            beforeEach(async() => {
                page = new Page();
                driver = page.driver;
                await page.visit('https://www.google.com/');
            });

            afterEach(async() => {
                await page.quit();
            });

            it('find the input box and google search button', async() => {
                const result = await page.findInputAndButton();
                console.log(result);
                expect(result.inputEnabled).to.equal(true);
                expect(result.buttonText).to.include('Google');
            });

            it('put keyword in search box and click search button', async() => {
                const result = await page.submitKeywordAndGetResult();
                expect(result.length).to.be.above(10);
            });
        });
    } catch (ex) {
        console.log(new Error(ex.message));
    } finally {

    }
})();

/i.stack.imgur.com/SD9Or.jpg

0 个答案:

没有答案
相关问题