From c2d9d0fcbcfd91dd2ef1bddee2ac8ea9e5e972b1 Mon Sep 17 00:00:00 2001 From: ShGulnaz Date: Thu, 15 Apr 2021 21:36:17 +0300 Subject: [PATCH 1/8] add wrong-auth test --- package.json | 14 ++++++++++++++ test/test-ui.js | 30 ++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 package.json create mode 100644 test/test-ui.js diff --git a/package.json b/package.json new file mode 100644 index 0000000..103dafb --- /dev/null +++ b/package.json @@ -0,0 +1,14 @@ +{ + "name": "arch-front", + "version": "1.0.0", + "scripts": { + "test": "./node_modules/.bin/_mocha test/test-ui.js" + }, + "dependencies": { + "geckodriver": "^1.22.3" + }, + "devDependencies": { + "mocha": "^8.3.2", + "selenium-webdriver": "^4.0.0-beta.3" + } +} diff --git a/test/test-ui.js b/test/test-ui.js new file mode 100644 index 0000000..27585d1 --- /dev/null +++ b/test/test-ui.js @@ -0,0 +1,30 @@ +// Generated by Selenium IDE +require('geckodriver') +const { Builder, By} = require('selenium-webdriver') +const assert = require('assert') + +async function sleep(msec) { return new Promise(resolve => setTimeout(resolve, msec)); } + +describe('test', function() { + this.timeout(30000) + let driver + let vars + beforeEach(async function() { + driver = await new Builder().forBrowser('firefox').build() + vars = {} + }) + after(async function() { + await driver.quit(); + }) + it('wrong-auth', async function() { + await driver.get("http://localhost:63342/arch-front/auth.html") + await sleep(3000) + await driver.findElement(By.id("username")).click() + await driver.findElement(By.id("username")).sendKeys("qweegrggrew") + await driver.findElement(By.id("password")).click() + await driver.findElement(By.id("password")).sendKeys("qwegrewreg") + await driver.findElement(By.css("input:nth-child(3)")).click() + await sleep(3000) + assert.strictEqual(await driver.getCurrentUrl(), 'http://localhost:63342/arch-front/auth.html'); + }) +}) From 005ac3abd8d6c053b9b47981504f6d826b5057cc Mon Sep 17 00:00:00 2001 From: DinoBambino69 Date: Thu, 15 Apr 2021 21:57:30 +0300 Subject: [PATCH 2/8] test-ui register add --- test/test-ui.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/test-ui.js b/test/test-ui.js index 27585d1..1074960 100644 --- a/test/test-ui.js +++ b/test/test-ui.js @@ -27,4 +27,17 @@ describe('test', function() { await sleep(3000) assert.strictEqual(await driver.getCurrentUrl(), 'http://localhost:63342/arch-front/auth.html'); }) + + it('register', async function() { + await driver.get("http://localhost:63342/arch-front/registration.html") + await driver.findElement(By.id("username")).click() + await driver.findElement(By.id("username")).sendKeys("ttt") + await driver.findElement(By.id("email")).click() + await driver.findElement(By.id("email")).sendKeys("ttt@mail.ru") + await driver.findElement(By.id("password")).click() + await driver.findElement(By.id("password")).sendKeys("ttt") + await driver.findElement(By.css("input:nth-child(4)")).click() + await sleep(3000) + assert.strictEqual(await driver.getCurrentUrl(), 'http://localhost:63342/arch-front/auth.html'); + }) }) From b1fe93546d92f4ead4c635c17a93eb49c1d43fc6 Mon Sep 17 00:00:00 2001 From: Mihaylova Yuliya Date: Thu, 15 Apr 2021 22:00:12 +0300 Subject: [PATCH 3/8] added test for correct auth --- test/test-ui.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/test/test-ui.js b/test/test-ui.js index 1074960..361ba85 100644 --- a/test/test-ui.js +++ b/test/test-ui.js @@ -27,7 +27,6 @@ describe('test', function() { await sleep(3000) assert.strictEqual(await driver.getCurrentUrl(), 'http://localhost:63342/arch-front/auth.html'); }) - it('register', async function() { await driver.get("http://localhost:63342/arch-front/registration.html") await driver.findElement(By.id("username")).click() @@ -40,4 +39,14 @@ describe('test', function() { await sleep(3000) assert.strictEqual(await driver.getCurrentUrl(), 'http://localhost:63342/arch-front/auth.html'); }) -}) + it('auth', async function() { + await driver.get("http://localhost:63342/arch-front/auth.html") + await driver.findElement(By.id("username")).click() + await driver.findElement(By.id("username")).sendKeys("ttt") + await driver.findElement(By.id("password")).click() + await driver.findElement(By.id("password")).sendKeys("ttt") + await driver.findElement(By.css("input:nth-child(3)")).click() + await sleep(3000) + assert.strictEqual(await driver.getCurrentUrl(), 'http://localhost:63342/arch-front/index.html'); + }) +}) \ No newline at end of file From 5fc939d4f8f850b4a31d2d3f2a9fb6652c637036 Mon Sep 17 00:00:00 2001 From: a_faskhutdinov Date: Thu, 15 Apr 2021 14:21:12 -0500 Subject: [PATCH 4/8] add test for checking addition string value --- test/test-ui.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/test-ui.js b/test/test-ui.js index 361ba85..4a4ab79 100644 --- a/test/test-ui.js +++ b/test/test-ui.js @@ -9,7 +9,7 @@ describe('test', function() { this.timeout(30000) let driver let vars - beforeEach(async function() { + before(async function() { driver = await new Builder().forBrowser('firefox').build() vars = {} }) @@ -49,4 +49,13 @@ describe('test', function() { await sleep(3000) assert.strictEqual(await driver.getCurrentUrl(), 'http://localhost:63342/arch-front/index.html'); }) + it('add string', async function() { + await driver.get("http://localhost:63342/arch-front/index.html") + await driver.findElement(By.id("input")).click() + await driver.findElement(By.id("input")).sendKeys("string") + await driver.findElement(By.css("input:nth-child(3)")).click() + await sleep(3000) + var categories = await driver.findElement(By.id("categories")).getText() + assert.strictEqual(categories, 'plain/text'); + }) }) \ No newline at end of file From f89a8bdcdf49bc8c8de46c5a331e18fd5bb255c9 Mon Sep 17 00:00:00 2001 From: ARManakhov Date: Thu, 15 Apr 2021 22:24:42 +0300 Subject: [PATCH 5/8] add test for checking delete string value --- test/test-ui.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/test-ui.js b/test/test-ui.js index 4a4ab79..8f1a21a 100644 --- a/test/test-ui.js +++ b/test/test-ui.js @@ -58,4 +58,11 @@ describe('test', function() { var categories = await driver.findElement(By.id("categories")).getText() assert.strictEqual(categories, 'plain/text'); }) -}) \ No newline at end of file + it('delete string', async function() { + await driver.get("http://localhost:63342/arch-front/index.html") + await driver.findElement(By.linkText("plain/text")).click() + await sleep(3000) + var categories = await driver.findElement(By.id("categories")).getText() + assert.notStrictEqual(categories, 'plain/text'); + }) +}) From 75854b405023a9df7f9833d8baf724e03375b9f6 Mon Sep 17 00:00:00 2001 From: Danil Apsadikov Date: Thu, 15 Apr 2021 23:24:49 +0300 Subject: [PATCH 6/8] added --- test/test-ui.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/test-ui.js b/test/test-ui.js index 8f1a21a..239381b 100644 --- a/test/test-ui.js +++ b/test/test-ui.js @@ -16,6 +16,13 @@ describe('test', function() { after(async function() { await driver.quit(); }) + it('register from auth', async function() { + await driver.get("http://localhost:63342/arch-front/auth.html") + await sleep(1000) + await driver.findElement(By.xpath("//*[text()[contains(.,'Registration')]]")).click(); + await sleep(3000) + assert.strictEqual(await driver.getCurrentUrl(), 'http://localhost:63342/arch-front/registration.html'); + }) it('wrong-auth', async function() { await driver.get("http://localhost:63342/arch-front/auth.html") await sleep(3000) @@ -65,4 +72,14 @@ describe('test', function() { var categories = await driver.findElement(By.id("categories")).getText() assert.notStrictEqual(categories, 'plain/text'); }) + it('add file', async function() { + await driver.get("http://localhost:63342/arch-front/index.html") + var fileInput = By.css("input[type=file]"); + var filePath = "C:\\Users\\Гульназ\\Pictures\\Screenshots\\8.1.png"; + await driver.findElement(fileInput).sendKeys(filePath); + await driver.findElement(By.css("input:nth-child(3)")).click() + await sleep(6000) + var categories = await driver.findElement(By.id("categories")).getText() + assert.strictEqual(categories, 'image/png'); + }) }) From da84c02665c283e48d7e6d270e295a3e4e2562ce Mon Sep 17 00:00:00 2001 From: Danil Apsadikov Date: Fri, 16 Apr 2021 07:16:35 +0300 Subject: [PATCH 7/8] update --- test/test-ui.js | 205 ++++++++++++++++++++++++++++++------------------ 1 file changed, 127 insertions(+), 78 deletions(-) diff --git a/test/test-ui.js b/test/test-ui.js index 239381b..571de0d 100644 --- a/test/test-ui.js +++ b/test/test-ui.js @@ -1,85 +1,134 @@ -// Generated by Selenium IDE +//import requirement packages require('geckodriver') const { Builder, By} = require('selenium-webdriver') const assert = require('assert') +//a function to timeout for a few seconds (it is necessary for the pages to have time to load) async function sleep(msec) { return new Promise(resolve => setTimeout(resolve, msec)); } describe('test', function() { - this.timeout(30000) - let driver - let vars - before(async function() { - driver = await new Builder().forBrowser('firefox').build() - vars = {} - }) - after(async function() { - await driver.quit(); - }) - it('register from auth', async function() { - await driver.get("http://localhost:63342/arch-front/auth.html") - await sleep(1000) - await driver.findElement(By.xpath("//*[text()[contains(.,'Registration')]]")).click(); - await sleep(3000) - assert.strictEqual(await driver.getCurrentUrl(), 'http://localhost:63342/arch-front/registration.html'); - }) - it('wrong-auth', async function() { - await driver.get("http://localhost:63342/arch-front/auth.html") - await sleep(3000) - await driver.findElement(By.id("username")).click() - await driver.findElement(By.id("username")).sendKeys("qweegrggrew") - await driver.findElement(By.id("password")).click() - await driver.findElement(By.id("password")).sendKeys("qwegrewreg") - await driver.findElement(By.css("input:nth-child(3)")).click() - await sleep(3000) - assert.strictEqual(await driver.getCurrentUrl(), 'http://localhost:63342/arch-front/auth.html'); - }) - it('register', async function() { - await driver.get("http://localhost:63342/arch-front/registration.html") - await driver.findElement(By.id("username")).click() - await driver.findElement(By.id("username")).sendKeys("ttt") - await driver.findElement(By.id("email")).click() - await driver.findElement(By.id("email")).sendKeys("ttt@mail.ru") - await driver.findElement(By.id("password")).click() - await driver.findElement(By.id("password")).sendKeys("ttt") - await driver.findElement(By.css("input:nth-child(4)")).click() - await sleep(3000) - assert.strictEqual(await driver.getCurrentUrl(), 'http://localhost:63342/arch-front/auth.html'); - }) - it('auth', async function() { - await driver.get("http://localhost:63342/arch-front/auth.html") - await driver.findElement(By.id("username")).click() - await driver.findElement(By.id("username")).sendKeys("ttt") - await driver.findElement(By.id("password")).click() - await driver.findElement(By.id("password")).sendKeys("ttt") - await driver.findElement(By.css("input:nth-child(3)")).click() - await sleep(3000) - assert.strictEqual(await driver.getCurrentUrl(), 'http://localhost:63342/arch-front/index.html'); - }) - it('add string', async function() { - await driver.get("http://localhost:63342/arch-front/index.html") - await driver.findElement(By.id("input")).click() - await driver.findElement(By.id("input")).sendKeys("string") - await driver.findElement(By.css("input:nth-child(3)")).click() - await sleep(3000) - var categories = await driver.findElement(By.id("categories")).getText() - assert.strictEqual(categories, 'plain/text'); - }) - it('delete string', async function() { - await driver.get("http://localhost:63342/arch-front/index.html") - await driver.findElement(By.linkText("plain/text")).click() - await sleep(3000) - var categories = await driver.findElement(By.id("categories")).getText() - assert.notStrictEqual(categories, 'plain/text'); - }) - it('add file', async function() { - await driver.get("http://localhost:63342/arch-front/index.html") - var fileInput = By.css("input[type=file]"); - var filePath = "C:\\Users\\Гульназ\\Pictures\\Screenshots\\8.1.png"; - await driver.findElement(fileInput).sendKeys(filePath); - await driver.findElement(By.css("input:nth-child(3)")).click() - await sleep(6000) - var categories = await driver.findElement(By.id("categories")).getText() - assert.strictEqual(categories, 'image/png'); - }) -}) + this.timeout(30000) + let driver + let vars + //function to be called before tests + before(async function() { + //open a new window in the firefox browser + driver = await new Builder().forBrowser('firefox').build() + vars = {} + }) + //a function that is called after the tests have passed + after(async function() { + //close the browser window + await driver.quit(); + }) + // тест, проверяющий кнопку регистрации страницы auth + it('register from auth', async function() { + await driver.get("http://localhost:63342/arch-front/auth.html%22") + await sleep(1000) + await driver.findElement(By.xpath("//*[text()[contains(.,'Registration')]]")).click(); + await sleep(3000) + // assert на то, что после нажатия мы находимся на странице регистрации + assert.strictEqual(await driver.getCurrentUrl(), 'http://localhost:63342/arch-front/registration.html%27'); + }) + //test for checking incorrect authorization + // when the user enters a username and password that does not exist + // in the database, he is thrown out on the authorization page again + it('wrong-auth', async function() { + //go to url + await driver.get("http://localhost:63342/arch-front/auth.html") + //waiting for the page to load + await sleep(3000) + //enters username + await driver.findElement(By.id("username")).click() + await driver.findElement(By.id("username")).sendKeys("qweegrggrew") + //enters password + await driver.findElement(By.id("password")).click() + await driver.findElement(By.id("password")).sendKeys("qwegrewreg") + //clicks on the authorize button + await driver.findElement(By.css("input:nth-child(3)")).click() + //waiting for the page to load + await sleep(3000) + //if the data is entered incorrectly, the user should be on the authorization page + //check which page the user is on and compare with the required + assert.strictEqual(await driver.getCurrentUrl(), 'http://localhost:63342/arch-front/auth.html'); + }) + //Тестирование регистрации + it('register', async function() { + //URL + await driver.get("http://localhost:63342/arch-front/registration.html") + //Ввод имени пользователя + await driver.findElement(By.id("username")).click() + await driver.findElement(By.id("username")).sendKeys("ttt") + //Ввод email адреса + await driver.findElement(By.id("email")).click() + await driver.findElement(By.id("email")).sendKeys("ttt@mail.ru") + //Ввод пароля + await driver.findElement(By.id("password")).click() + await driver.findElement(By.id("password")).sendKeys("ttt") + await driver.findElement(By.css("input:nth-child(4)")).click() + await sleep(3000) + //Проверка редиректа страницы регистрации при успешной регистрации + assert.strictEqual(await driver.getCurrentUrl(), 'http://localhost:63342/arch-front/auth.html'); + }) + // correct auth test + // testing existing user with correct password + // we expect that when user is authorized a page with files is opened + it('auth', async function() { + // go to the authorization page + await driver.get("http://localhost:63342/arch-front/auth.html") + // click on the field with username + await driver.findElement(By.id("username")).click() + // set there the username of an existing user + await driver.findElement(By.id("username")).sendKeys("ttt") + // click on the field with password + await driver.findElement(By.id("password")).click() + // set there the correct password of user + await driver.findElement(By.id("password")).sendKeys("ttt") + // click on the authorization button + await driver.findElement(By.css("input:nth-child(3)")).click() + // wait 3 seconds for the changes to be loaded + await sleep(3000) + // check that we were redirected to the correct page + assert.strictEqual(await driver.getCurrentUrl(), 'http://localhost:63342/arch-front/index.html'); + }) + /** + * Test to check addition text input in index.html + * Test goes to index.html and input "string" as input value + * then checks if its appear in page as a download option + */ + it('add string', async function() { + await driver.get("http://localhost:63342/arch-front/index.html") + await driver.findElement(By.id("input")).click() + await driver.findElement(By.id("input")).sendKeys("string") + await driver.findElement(By.css("input:nth-child(3)")).click() + await sleep(3000) + var categories = await driver.findElement(By.id("categories")).getText() + assert.strictEqual(categories, 'plain/text'); + }) + /** + * Test to check delete category on download + * Click ot href with text 'plain/text' + * check if category don't contains 'plain/text' after click + */ + it('delete string', async function() { + await driver.get("http://localhost:63342/arch-front/index.html") + await driver.findElement(By.linkText("plain/text")).click() + await sleep(3000) + var categories = await driver.findElement(By.id("categories")).getText() + assert.notStrictEqual(categories, 'plain/text'); + }) + + /* + * Test to check that file uploaded + */ + it('add file', async function() { + await driver.get("http://localhost:63342/arch-front/index.html") + var fileInput = By.css("input[type=file]"); + var filePath = "C:\\Users\\Гульназ\\Pictures\\Screenshots\\8.1.png"; + await driver.findElement(fileInput).sendKeys(filePath); + await driver.findElement(By.css("input:nth-child(3)")).click() + await sleep(6000) + var categories = await driver.findElement(By.id("categories")).getText() + assert.strictEqual(categories, 'image/png'); + }) +}) \ No newline at end of file From 69f54b54bdc2abed6672542dd68d4cda5f2acaa3 Mon Sep 17 00:00:00 2001 From: Danil Apsadikov Date: Fri, 16 Apr 2021 11:09:31 +0300 Subject: [PATCH 8/8] added comments --- test/test-ui.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/test-ui.js b/test/test-ui.js index 571de0d..093d41a 100644 --- a/test/test-ui.js +++ b/test/test-ui.js @@ -120,6 +120,11 @@ describe('test', function() { /* * Test to check that file uploaded + * Go to the page + * Upload a file + * Press the button + * Get categories + * Check that category added and image was uploaded */ it('add file', async function() { await driver.get("http://localhost:63342/arch-front/index.html")