-2
Can someone tell me a solution?
Running $ npm test -- -spec=usingPageObjectTest.js does not work:
[email protected] test C:\wagner.galvao\node\webdriverioframework
wdio wdio.conf.js "--spec=usingPageObjectTest.js"
Execution of 1 spec files started at 2020-10-13T14:26:40.109Z
[0-0] RUNNING in chrome - C:\wagner.galvao\node\webdriverioframework\test\specs\usingPageObjectTest.js
[0-0] PASSED in chrome - C:\wagner.galvao\node\webdriverioframework\test\specs\usingPageObjectTest.js
Spec Files: 1 passed, 1 total (100% completed) in 00:00:14
[0-0] beforeEach
[0-0] it => Deve enviar mensagem com sucesso
[0-0] PASSED in chrome - C:\wagner.galvao\node\webdriverioframework\test\specs\usingPageObjectTest.js
Running without contactUsPage lines works:
//const { default: contactUsPage } = require("../../pages/contactUs.page");
beforeEach(() => {
console.log('beforeEach');
browser.url('/Contact-Us/contactus.html');
//contactUsPage.openPage();
})
describe('Testar o formulário de contato', () => {
it('Deve enviar mensagem com sucesso', () => {
console.log('it => Deve enviar mensagem com sucesso');
});
});
$ npm test -- --spec=usingPageObjectTest.js
[email protected] test C:\wagner.galvao\node\webdriverioframework
wdio wdio.conf.js "--spec=usingPageObjectTest.js"
Execution of 1 spec files started at 2020-10-13T14:43:38.687Z
[0-0] RUNNING in chrome - C:\wagner.galvao\node\webdriverioframework\test\specs\usingPageObjectTest.js
[0-0] beforeEach
[0-0] it => Deve enviar mensagem com sucesso
[0-0] PASSED in chrome - C:\wagner.galvao\node\webdriverioframework\test\specs\usingPageObjectTest.js
"spec" Reporter:
------------------------------------------------------------------
[chrome 86.0.4240.75 windows #0-0] Spec: C:\wagner.galvao\node\webdriverioframework\test\specs\usingPageObjectTest.js
[chrome 86.0.4240.75 windows #0-0] Running: chrome (v86.0.4240.75) on windows
[chrome 86.0.4240.75 windows #0-0] Session ID: fd8f361cf51492de470e10a05ef04f7e
[chrome 86.0.4240.75 windows #0-0]
[chrome 86.0.4240.75 windows #0-0] Testar o formulário de contato
[chrome 86.0.4240.75 windows #0-0] ✓ Deve enviar mensagem com sucesso
[chrome 86.0.4240.75 windows #0-0]
[chrome 86.0.4240.75 windows #0-0] 1 passing (2.6s)
Spec Files: 1 passed, 1 total (100% completed) in 00:00:16
My files:
//test\specs\usingPageObjectTest.js
const { default: contactUsPage } = require("../../pages/contactUs.page");
beforeEach(() => {
console.log('beforeEach');
// browser.url('/Contact-Us/contactus.html');
contactUsPage.openPage();
})
describe('Testar o formulário de contato', () => {
it('Deve enviar mensagem com sucesso', () => {
console.log('it => Deve enviar mensagem com sucesso');
});
});
//pages\contactUs.page.js
const { default: contactUsConfig } = require("../config/contactUs.config");
const { default: elementActions } = require("../utils/elementActions");
class ContactUsPage {
openPage() {
elementActions.doGoToPage(contactUsConfig.pageUri());
}
}
export default new ContactUsPage();
//utils\elementActions.js
class ElementActions {
doGoToPage(text) {
browser.Url(text)
}
}
export default new ElementActions();
//config\contactUs.config.js
class ContactUsConfig {
// Page Elements
get pageTitle() { return 'WebDriver | Contact Us'; }
get pageUri() { return '/Contact-Us/contactus.html'; }
get pageUrl() { return 'http://www.webdriveruniversity.com'; }
}
export default new ContactUsConfig();