From b80756b687957245fb79aa3656616509e4d2dfbb Mon Sep 17 00:00:00 2001 From: Dawid Majsnerowski Date: Fri, 29 Nov 2019 22:16:18 +0100 Subject: [PATCH 01/10] BES-26 | First test for BestNotes --- package-lock.json | 53 ++++++ package.json | 1 + test/config/base.conf.js | 3 + test/specs/base/base.js | 168 ++++++++++++++++++++ test/specs/base/common.js | 10 ++ test/specs/base/navigation.js | 14 ++ test/specs/components/login.js | 15 ++ test/specs/suites/desktop/loginpage.test.js | 17 ++ test/specs/testfile.webdriver.js | 9 -- 9 files changed, 281 insertions(+), 9 deletions(-) create mode 100644 test/specs/base/base.js create mode 100644 test/specs/base/common.js create mode 100644 test/specs/base/navigation.js create mode 100644 test/specs/components/login.js create mode 100644 test/specs/suites/desktop/loginpage.test.js delete mode 100644 test/specs/testfile.webdriver.js diff --git a/package-lock.json b/package-lock.json index c32d3f1..3293ef4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -347,6 +347,12 @@ "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" }, + "assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "dev": true + }, "async": { "version": "2.6.3", "resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", @@ -538,6 +544,20 @@ "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" }, + "chai": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", + "integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==", + "dev": true, + "requires": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^3.0.1", + "get-func-name": "^2.0.0", + "pathval": "^1.1.0", + "type-detect": "^4.0.5" + } + }, "chalk": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", @@ -553,6 +573,12 @@ "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", "dev": true }, + "check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", + "dev": true + }, "chokidar": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.3.0.tgz", @@ -803,6 +829,15 @@ "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", "dev": true }, + "deep-eql": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", + "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", + "dev": true, + "requires": { + "type-detect": "^4.0.0" + } + }, "deep-is": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", @@ -1166,6 +1201,12 @@ "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", "dev": true }, + "get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", + "dev": true + }, "getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", @@ -2276,6 +2317,12 @@ "pinkie-promise": "^2.0.0" } }, + "pathval": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", + "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", + "dev": true + }, "pend": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", @@ -2778,6 +2825,12 @@ "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" }, + "type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true + }, "type-fest": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", diff --git a/package.json b/package.json index 0079a61..c894fb6 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "@wdio/mocha-framework": "^5.16.5", "@wdio/spec-reporter": "^5.16.5", "@wdio/sync": "^5.16.5", + "chai": "^4.2.0", "chromedriver": "^78.0.1", "wdio-chromedriver-service": "^5.0.2" }, diff --git a/test/config/base.conf.js b/test/config/base.conf.js index 00993ac..436bf60 100644 --- a/test/config/base.conf.js +++ b/test/config/base.conf.js @@ -1,6 +1,9 @@ exports.config = { runner: 'local', path: '/', + suites: { + login: ['./test/specs/suites/desktop/loginpage.test.js'], + }, specs: [ './test/specs/**/*.js' ], diff --git a/test/specs/base/base.js b/test/specs/base/base.js new file mode 100644 index 0000000..c576431 --- /dev/null +++ b/test/specs/base/base.js @@ -0,0 +1,168 @@ +class Base { + click(selector, elementName) { + try { + $(selector).scrollIntoView({ block: 'center' }); + $(selector).waitForEnabled(); + $(selector).click(); + console.log(`${elementName} was clicked`); + } catch (err) { + console.log(`${elementName} was not clicked. Exception: ${err}`); + } + } + + clickNth(selector, position, elementName) { + try { + $$(selector)[position].scrollIntoView({ block: 'center' }); + $$(selector)[position].waitForEnabled(); + $$(selector)[position].click(); + console.log(`${elementName} with position: ${position} was clicked`); + } catch (err) { + console.log(`${elementName} with position: ${position} was not clicked. Exception: ${err}`); + } + } + + clearInput(selector) { + try { + const valueLength = $(selector).getValue().length; + const backSpaces = new Array(valueLength).fill('Backspace'); + $(selector).setValue(backSpaces); + console.log(`${selector} has length: ${valueLength} and was cleared`); + } catch (e) { + console.log(`${selector} was not cleared with exception: ${e}`); + } + } + + fillIn(selector, text, elementName) { + console.log(`${elementName} is displayed`); + try { + this.clearInput(selector); + $(selector).setValue(text); + console.log(`${text} was added to ${elementName}`); + } catch (err) { + console.log(`An exception occurred when adding a text to the element: ${err}`); + } + } + + fillInNth(selectorList, position, text, elementName) { + try { + $$(selectorList)[position].setValue(text); + console.log(`${text} was added to ${elementName}`); + } catch (err) { + console.log(`An exception occurred when adding a text to the element: ${err}`); + } + } + + getAttribute(selector, attribute, elementName) { + let attributeValue = null; + try { + console.log(`${elementName} was displayed`); + attributeValue = $(selector).getAttribute(attribute); + console.log(`${elementName} had value: ${attributeValue}`); + } catch (err) { + console.log(`Could not get ${elementName}. Exception: ${err}`); + } + + return attributeValue; + } + + getLinkFromElementsArray(selector, position, elementName) { + let href = null; + try { + href = $$(selector)[position].$('a').getAttribute('href').replace('%20', '_'); + console.log(`Link for ${elementName} with position ${position} has value: ${href}`); + } catch (err) { + console.log(`Could not get link for ${elementName}. Exception: ${err}`); + } + + return href; + } + + isEnabled(selector, elementName) { + console.log(`${elementName} is displayed`); + const isEnabled = $(selector).isEnabled(); + console.log(`${elementName} is enabled: ${isEnabled}`); + + return isEnabled; + } + + isDisplayed(selector, elementName, customTimeout) { + let isDisplayed = false; + try { + isDisplayed = $(selector).isDisplayed(customTimeout, true); + console.log(`${elementName} is displayed: ${isDisplayed}`); + } catch (err) { + console.log(`${elementName} is displayed: ${isDisplayed}. Exception: ${err}`); + } + + return isDisplayed; + } + + isNthDisplayed(selectorsList, position, elementName, customTimeout) { + let isDisplayed = false; + try { + isDisplayed = $$(selectorsList)[position].isDisplayed(customTimeout, true); + console.log(`${elementName} with position ${position} is displayed: ${isDisplayed}`); + } catch (err) { + console.log(`${elementName} with position ${position} is displayed: ${isDisplayed}. Exception: ${err}`); + } + + return isDisplayed; + } + + waitForDisplayed(selector, elementName) { + browser.waitUntil(() => { + try { + return $(selector).isDisplayed(); + } catch (e) { + console.log(`${elementName} is not displayed. Exception: ${e}`); + return false; + } + }, 5000, `Expected ${selector} to be displayed after 5s`); + } + + waitForNthElementDisplayed(selectorList, position, elementName) { + browser.waitUntil(() => { + try { + return $$(selectorList)[position].isDisplayed(); + } catch (e) { + console.log(`${elementName} with position ${position} is not displayed. Exception: ${e}`); + return false; + } + }, 5000, `Expected ${elementName} with position ${position} to be displayed after 5s`, 500); + } + + waitForNotDisplayed(selector, elementName, customTimeout) { + browser.waitUntil(() => { + try { + return !$(selector).isDisplayed(customTimeout, true); + } catch (e) { + console.log(`${elementName} is still displayed. Exception: ${e}`); + return true; + } + }, 5000, `Expected ${elementName} to be displayed after 5s`, 500); + } + + waitForEnabled(selector, elementName) { + browser.waitUntil(() => { + try { + return !$(selector).isEnabled(); + } catch (e) { + console.log(`${elementName} is not enabled. Exception: ${e}`); + return true; + } + }, 5000, `Expected ${selector} to be enabled after 5s`, 500); + } + + isChildDisplayedForParent(parentElementSelector, position, childElementSelector, childElementName) { + const isDisplayed = $$(parentElementSelector)[position].$(childElementSelector).isDisplayed(); + console.log(`${childElementName} is displayed: ${isDisplayed}`); + + return isDisplayed; + } + + wait(timeout) { + setTimeout(() => { console.log(`This is a explicit wait of ${timeout}`); }, timeout); + } +} + +module.exports = new Base(); \ No newline at end of file diff --git a/test/specs/base/common.js b/test/specs/base/common.js new file mode 100644 index 0000000..f7e103a --- /dev/null +++ b/test/specs/base/common.js @@ -0,0 +1,10 @@ +class Common { + constructor() { + this.loremIpsum = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.'; + this.ecceIpsum = 'Snare hope zarathustra pious society. Ascetic ocean snare chaos endless war ultimate insofar right god spirit. Right free pinnacle philosophy overcome self philosophy. Right passion value dead truth faithful deceptions. Marvelous hatred derive superiority deceptions justice overcome oneself zarathustra gains.'; + this.bestNotesLink = 'http://bestnotes.pythonanywhere.com/bestnotes/'; + } + +} + +module.exports = new Common(); \ No newline at end of file diff --git a/test/specs/base/navigation.js b/test/specs/base/navigation.js new file mode 100644 index 0000000..e4143f1 --- /dev/null +++ b/test/specs/base/navigation.js @@ -0,0 +1,14 @@ +const base = require('./base'); +const Login = require('../components/login'); + +class Navigation { + constructor() { + this.loginUrl = 'http://bestnotes.pythonanywhere.com/bestnotes/accounts/login/'; + } + + toLoginPage() { + browser.url(this.loginUrl); + return new Login(); + } +} +module.exports = new Navigation(); diff --git a/test/specs/components/login.js b/test/specs/components/login.js new file mode 100644 index 0000000..77de129 --- /dev/null +++ b/test/specs/components/login.js @@ -0,0 +1,15 @@ +const path = require('path'); +const base = require('../base/base'); + +class Login { + constructor() { + this.loginForm = '.login-form-2'; + } + + isLoginFormDisplayed() { + base.waitForDisplayed(this.loginForm); + return base.isDisplayed(this.loginForm); + } +} + +module.exports = Login; \ No newline at end of file diff --git a/test/specs/suites/desktop/loginpage.test.js b/test/specs/suites/desktop/loginpage.test.js new file mode 100644 index 0000000..f7fb2b0 --- /dev/null +++ b/test/specs/suites/desktop/loginpage.test.js @@ -0,0 +1,17 @@ +const { addStep } = require('@wdio/allure-reporter').default; +const { expect } = require('chai'); + +const common = require('../../base/common'); +const navigate = require('../../base/navigation'); +const Login = require('../../components/login'); + +describe('Login page in BestNotes', () => { + + it('should be displayed', () => { + const login = new Login(); + navigate.toLoginPage(); + expect(login.isLoginFormDisplayed(), 'Login form should be displayed').to.be.true; + }) + + it +}); \ No newline at end of file diff --git a/test/specs/testfile.webdriver.js b/test/specs/testfile.webdriver.js deleted file mode 100644 index cc6037c..0000000 --- a/test/specs/testfile.webdriver.js +++ /dev/null @@ -1,9 +0,0 @@ -const assert = require('assert') - -describe('webdriver.io page', () => { - it('should have the right title', () => { - browser.url('https://webdriver.io') - const title = browser.getTitle() - assert.strictEqual(title, 'WebdriverIO · Next-gen WebDriver test framework for Node.js') - }) -}) \ No newline at end of file From 672caa2392a8649801caa15122a17d8930dbf774 Mon Sep 17 00:00:00 2001 From: Dawid Majsnerowski Date: Fri, 29 Nov 2019 22:18:40 +0100 Subject: [PATCH 02/10] BES-26 | Merge --- test/specs/suites/desktop/loginpage.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/specs/suites/desktop/loginpage.test.js b/test/specs/suites/desktop/loginpage.test.js index f7fb2b0..cd48b32 100644 --- a/test/specs/suites/desktop/loginpage.test.js +++ b/test/specs/suites/desktop/loginpage.test.js @@ -13,5 +13,4 @@ describe('Login page in BestNotes', () => { expect(login.isLoginFormDisplayed(), 'Login form should be displayed').to.be.true; }) - it }); \ No newline at end of file From c15c1eb22fecee8ec1a570fb29cfee566afdf171 Mon Sep 17 00:00:00 2001 From: Dawid Majsnerowski Date: Fri, 29 Nov 2019 22:51:45 +0100 Subject: [PATCH 03/10] BES-26 | Test for incorrect login --- test/specs/base/common.js | 1 + test/specs/components/login.js | 20 +++++++++++++++ test/specs/suites/desktop/loginpage.test.js | 27 +++++++++++++++++++-- 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/test/specs/base/common.js b/test/specs/base/common.js index f7e103a..7de8eef 100644 --- a/test/specs/base/common.js +++ b/test/specs/base/common.js @@ -3,6 +3,7 @@ class Common { this.loremIpsum = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.'; this.ecceIpsum = 'Snare hope zarathustra pious society. Ascetic ocean snare chaos endless war ultimate insofar right god spirit. Right free pinnacle philosophy overcome self philosophy. Right passion value dead truth faithful deceptions. Marvelous hatred derive superiority deceptions justice overcome oneself zarathustra gains.'; this.bestNotesLink = 'http://bestnotes.pythonanywhere.com/bestnotes/'; + this.errorLoginMessage = 'Nieprawidłowy adres e-mail lub hasło. Spróbuj ponownie!'; } } diff --git a/test/specs/components/login.js b/test/specs/components/login.js index 77de129..a3b4053 100644 --- a/test/specs/components/login.js +++ b/test/specs/components/login.js @@ -4,12 +4,32 @@ const base = require('../base/base'); class Login { constructor() { this.loginForm = '.login-form-2'; + this.emailField = '#id_username'; + this.passwordField = '#id_password'; + this.loginButton = '.btnSubmit'; + this.warringMessage = '.text-warning'; } isLoginFormDisplayed() { base.waitForDisplayed(this.loginForm); return base.isDisplayed(this.loginForm); } + + fillCredentials(selector, text) { + base.fillIn(selector, text, 'Fill credentials'); + return this; + } + + clickLoginButton() { + base.click(this.loginButton, 'Login button'); + return this; + } + + getErrorMessage() { + base.waitForDisplayed(this.warringMessage); + return base.getAttribute(this.warringMessage, 'textContent', 'Error message text'); + } + } module.exports = Login; \ No newline at end of file diff --git a/test/specs/suites/desktop/loginpage.test.js b/test/specs/suites/desktop/loginpage.test.js index cd48b32..4c6c673 100644 --- a/test/specs/suites/desktop/loginpage.test.js +++ b/test/specs/suites/desktop/loginpage.test.js @@ -5,12 +5,35 @@ const common = require('../../base/common'); const navigate = require('../../base/navigation'); const Login = require('../../components/login'); -describe('Login page in BestNotes', () => { +const testName = 'test'; +describe('Login page in BestNotes', () => { it('should be displayed', () => { const login = new Login(); + + addStep('Redirect to Login Page'); navigate.toLoginPage(); + + addStep('Check if Login Form is displayed and URL '); + expect(browser.getUrl(), 'Post details URL should include post ID').to.equal(common.bestNotesLink + 'accounts/login/'); expect(login.isLoginFormDisplayed(), 'Login form should be displayed').to.be.true; }) - + + it('shouldnt logged user with incorrect credentials', () => { + const login = new Login(); + + addStep('Redirect to Login Page'); + navigate.toLoginPage(); + + addStep('Check if Login Form is displayed'); + expect(login.isLoginFormDisplayed(), 'Login form should be displayed').to.be.true; + + addStep('Fill credentials and try to login'); + login.fillCredentials(login.emailField, testName); + login.fillCredentials(login.passwordField, testName); + login.clickLoginButton(); + + addStep('Check if the error message is displayed'); + expect(login.getErrorMessage(), 'Message about wrong credentials should be displayed').to.equal(common.errorLoginMessage); +}) }); \ No newline at end of file From af936b727b861e8ce0e92590829ed5a725c6bf96 Mon Sep 17 00:00:00 2001 From: Dawid Majsnerowski Date: Fri, 29 Nov 2019 23:22:08 +0100 Subject: [PATCH 04/10] Fix for Jenkins --- package.json | 1 + test/config/base.conf.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index c894fb6..62418f8 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "@wdio/sync": "^5.16.5", "chai": "^4.2.0", "chromedriver": "^78.0.1", + "deepmerge": "^4.2.2", "wdio-chromedriver-service": "^5.0.2" }, "dependencies": { diff --git a/test/config/base.conf.js b/test/config/base.conf.js index 436bf60..52dac63 100644 --- a/test/config/base.conf.js +++ b/test/config/base.conf.js @@ -14,7 +14,7 @@ exports.config = { maxInstances: 5, browserName: 'chrome', 'goog:chromeOptions': { - args: ['--no-sandbox', '--disable-dev-shm-usage','--headless','--start-maximized'], + args: ['--no-sandbox'], }, }], From 04e0b933cf4fac95d6434b29a3a52f9294626301 Mon Sep 17 00:00:00 2001 From: Dawid Majsnerowski Date: Fri, 29 Nov 2019 23:25:48 +0100 Subject: [PATCH 05/10] Fix for Jenkins --- test/config/base.conf.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/config/base.conf.js b/test/config/base.conf.js index 52dac63..436bf60 100644 --- a/test/config/base.conf.js +++ b/test/config/base.conf.js @@ -14,7 +14,7 @@ exports.config = { maxInstances: 5, browserName: 'chrome', 'goog:chromeOptions': { - args: ['--no-sandbox'], + args: ['--no-sandbox', '--disable-dev-shm-usage','--headless','--start-maximized'], }, }], From 10db28eccf395867a90f8ab8495bebf4161106c2 Mon Sep 17 00:00:00 2001 From: Dawid Majsnerowski Date: Fri, 29 Nov 2019 23:25:57 +0100 Subject: [PATCH 06/10] Fix for Jenkins --- test/config/base.conf.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/config/base.conf.js b/test/config/base.conf.js index 436bf60..2becf10 100644 --- a/test/config/base.conf.js +++ b/test/config/base.conf.js @@ -14,7 +14,7 @@ exports.config = { maxInstances: 5, browserName: 'chrome', 'goog:chromeOptions': { - args: ['--no-sandbox', '--disable-dev-shm-usage','--headless','--start-maximized'], + args: ['--no-sandbox','--headless','--start-maximized'], }, }], From d0940dbbc6839e29ca9764752d0a89dc3b8198c1 Mon Sep 17 00:00:00 2001 From: Dawid Majsnerowski Date: Fri, 29 Nov 2019 23:27:57 +0100 Subject: [PATCH 07/10] Fix for Jenkins --- test/config/base.conf.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/config/base.conf.js b/test/config/base.conf.js index 2becf10..5a97c63 100644 --- a/test/config/base.conf.js +++ b/test/config/base.conf.js @@ -14,7 +14,7 @@ exports.config = { maxInstances: 5, browserName: 'chrome', 'goog:chromeOptions': { - args: ['--no-sandbox','--headless','--start-maximized'], + args: ['--no-sandbox','--start-maximized'], }, }], From e43b6d97098e543d16588ad79c77315444a37f47 Mon Sep 17 00:00:00 2001 From: Dawid Majsnerowski Date: Fri, 29 Nov 2019 23:28:18 +0100 Subject: [PATCH 08/10] Fix for Jenkins --- test/config/base.conf.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/config/base.conf.js b/test/config/base.conf.js index 5a97c63..2becf10 100644 --- a/test/config/base.conf.js +++ b/test/config/base.conf.js @@ -14,7 +14,7 @@ exports.config = { maxInstances: 5, browserName: 'chrome', 'goog:chromeOptions': { - args: ['--no-sandbox','--start-maximized'], + args: ['--no-sandbox','--headless','--start-maximized'], }, }], From 4a63d7df46050a793da300aff0761b789ecab573 Mon Sep 17 00:00:00 2001 From: Dawid Majsnerowski Date: Sat, 30 Nov 2019 11:47:16 +0100 Subject: [PATCH 09/10] BES-26 | adding new test --- test/config/base.conf.js | 1 + test/specs/components/subject.js | 14 +++++++++++ test/specs/suites/desktop/loginpage.test.js | 23 ++++++++++++++++++- test/specs/suites/desktop/subjectpage.test.js | 0 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 test/specs/components/subject.js create mode 100644 test/specs/suites/desktop/subjectpage.test.js diff --git a/test/config/base.conf.js b/test/config/base.conf.js index 2becf10..8421d4d 100644 --- a/test/config/base.conf.js +++ b/test/config/base.conf.js @@ -3,6 +3,7 @@ exports.config = { path: '/', suites: { login: ['./test/specs/suites/desktop/loginpage.test.js'], + subject: ['./test/specs/suites/desktop/subjectpage.test.js'], }, specs: [ './test/specs/**/*.js' diff --git a/test/specs/components/subject.js b/test/specs/components/subject.js new file mode 100644 index 0000000..dd47c4b --- /dev/null +++ b/test/specs/components/subject.js @@ -0,0 +1,14 @@ +const path = require('path'); +const base = require('../base/base'); + +class Subject { + constructor() { + this.subjectNavbar = '.navbar'; + } + + isNavbarDisplayed() { + base.waitForDisplayed(this.subjectNavbar); + return base.isDisplayed(this.subjectNavbar); + } +} +module.exports = Subject; \ No newline at end of file diff --git a/test/specs/suites/desktop/loginpage.test.js b/test/specs/suites/desktop/loginpage.test.js index 4c6c673..19cbee9 100644 --- a/test/specs/suites/desktop/loginpage.test.js +++ b/test/specs/suites/desktop/loginpage.test.js @@ -4,9 +4,11 @@ const { expect } = require('chai'); const common = require('../../base/common'); const navigate = require('../../base/navigation'); const Login = require('../../components/login'); - +const Subject = require('../../components/subject'); const testName = 'test'; +const corrrectName = 'admin'; + describe('Login page in BestNotes', () => { it('should be displayed', () => { const login = new Login(); @@ -36,4 +38,23 @@ describe('Login page in BestNotes', () => { addStep('Check if the error message is displayed'); expect(login.getErrorMessage(), 'Message about wrong credentials should be displayed').to.equal(common.errorLoginMessage); }) + +it('should logged user with correct credentials', () => { + const login = new Login(); + + addStep('Redirect to Login Page'); + navigate.toLoginPage(); + + addStep('Check if Login Form is displayed'); + expect(login.isLoginFormDisplayed(), 'Login form should be displayed').to.be.true; + + addStep('Fill credentials and try to login'); + login.fillCredentials(login.emailField, corrrectName); + login.fillCredentials(login.passwordField, corrrectName); + login.clickLoginButton(); + + addStep('Check if the page is displayed and URL matches'); + expect(browser.getUrl(), 'Post details URL should include post ID').to.equal(common.bestNotesLink + 'subject/'); + expect(new Subject().isNavbarDisplayed(), 'Subject page should be displayed').to.be.true; +}) }); \ No newline at end of file diff --git a/test/specs/suites/desktop/subjectpage.test.js b/test/specs/suites/desktop/subjectpage.test.js new file mode 100644 index 0000000..e69de29 From d2de735937ce6e495d1059372385518a19e73eca Mon Sep 17 00:00:00 2001 From: Dawid Majsnerowski Date: Sat, 30 Nov 2019 11:47:49 +0100 Subject: [PATCH 10/10] BES-26 | adding new test --- test/specs/suites/desktop/loginpage.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/specs/suites/desktop/loginpage.test.js b/test/specs/suites/desktop/loginpage.test.js index 19cbee9..34d36f1 100644 --- a/test/specs/suites/desktop/loginpage.test.js +++ b/test/specs/suites/desktop/loginpage.test.js @@ -7,7 +7,7 @@ const Login = require('../../components/login'); const Subject = require('../../components/subject'); const testName = 'test'; -const corrrectName = 'admin'; +const correctName = 'admin'; describe('Login page in BestNotes', () => { it('should be displayed', () => { @@ -49,8 +49,8 @@ it('should logged user with correct credentials', () => { expect(login.isLoginFormDisplayed(), 'Login form should be displayed').to.be.true; addStep('Fill credentials and try to login'); - login.fillCredentials(login.emailField, corrrectName); - login.fillCredentials(login.passwordField, corrrectName); + login.fillCredentials(login.emailField, correctName); + login.fillCredentials(login.passwordField, correctName); login.clickLoginButton(); addStep('Check if the page is displayed and URL matches');