我是WebdriverIO和Mocha的新手,我编写了2个测试以检查我们的Web应用程序。
运行第一个测试后,我想关闭浏览器并再次登录。当我使用时browser.close()
,我得到一个browser.close()
不是函数的错误,基本上第二个测试在第一个测试打开后立即运行。
在Mocha中进行测试后,是否可以关闭浏览器?
describe('Verify that a signed-in user can get to the page', () => {
it('Title assertion ', () => {
const viUrl = 'https://buyermanage.com/bmgt/lock?useMock=pre.json';
signInPage.signIn('rich221', 'password', viUrl);
assert.equal(preApp.getTitle(), 'Pre-App', 'Title Mismatch');
});
});
describe("Verify that a not signed-in user can't get to the page and is redirected to login page", () => {
it('Title assertion ', () => {
const viUrl = 'https://buyermanage.com/bmgt/lock?useMock=pre.json';
assert.equal(preApp.getTitle(), 'Pre-App', 'Title Mismatch');
});
});
after(() => {
// Start a new session for every 'locale' (wipe browser cache):
browser.reloadSession();
});
在您的特定示例中,您需要在afterEach()
钩子中使用它,并将语句(取决于您的测试套件要求)describes
分别包装在父块中:it
describe
describe('The world is your oister', () => {
describe('Verify that a signed-in user can get to the page', () => {
it('Title assertion ', () => {
// bla bla bla
});
});
describe("Verify that a not signed-in user can't get to the page and is redirected to login page", () => {
it('Title assertion ', () => {
// bla bla bla
});
});
afterEach(() => {
browser.reloadSession();
});
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句