From cfd8c33fb2591cd1dfee3c61d1c4fed3c69731b5 Mon Sep 17 00:00:00 2001 From: ksenipetrova Date: Sat, 13 May 2017 19:15:11 +0500 Subject: [PATCH 1/2] =?UTF-8?q?=D0=98=D1=81=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 6 ++++- tests/mongomart-test.js | 50 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 86058be..c7c11f9 100644 --- a/package.json +++ b/package.json @@ -3,11 +3,15 @@ "version": "0.0.1", "description": "Selenium", "scripts": { - "test": "wdio wdio.conf.js" + "test": "wdio wdio.conf.js", + "selenium:install": "selenium-standalone install", + "selenium:start": "selenium-standalone start" }, "author": "Sergey Zhigalov ", "license": "MIT", "devDependencies": { + "moment": "^2.18.1", + "selenium-standalone": "^6.4.1", "wdio-mocha-framework": "0.5.10", "wdio-sauce-service": "0.4.0", "wdio-spec-reporter": "0.1.0", diff --git a/tests/mongomart-test.js b/tests/mongomart-test.js index b2dccbc..6a3acee 100644 --- a/tests/mongomart-test.js +++ b/tests/mongomart-test.js @@ -1,5 +1,49 @@ +const assert = require('assert'); +const moment = require ('moment'); + describe('Mongomart', () => { - it('should ...', () => { - browser.url('http://urfu-2016-testing.herokuapp.com/'); - }); + it('should find one product by query "cup"', () => { + const data = browser + .url('/') + .addValue('input[name="query"]','cup') + .click('button[type="submit"]') + .elements('.row img'); + + assert.equal(data.value.length, 1); + }); + it('should be right navigation', () => { + browser.url('/item/11'); + + const actualTopLevel = browser.getText('.breadcrumb li:nth-child(1) a'); + const actualCategory = browser.getText('.breadcrumb li:nth-child(2) a'); + const actualItem = browser.getText('.breadcrumb li:nth-child(3)'); + const actualTopLevelHref = browser.getAttribute('.breadcrumb li:nth-child(1) a', 'href'); + const actualCategoryHref = browser.getAttribute('.breadcrumb li:nth-child(2) a', 'href'); + + assert.equal(actualTopLevel, 'Home'); + assert.equal(actualCategory, 'Books'); + assert.equal(actualItem, 'MongoDB The Definitive Guide'); + assert.equal(actualTopLevelHref, 'http://urfu-2016-testing.herokuapp.com/'); + assert.equal(actualCategoryHref, 'http://urfu-2016-testing.herokuapp.com/?category=Books'); + }); + it('should be same category when click on category link in navigation', () => { + browser.url('/item/11'); + + const expectedCategory = browser.getText('.breadcrumb li:nth-child(2) a'); + + browser.click('.breadcrumb li:nth-child(2) a'); + + const actualCategory = browser.getText('.breadcrumb li:nth-child(2)'); + + assert.equal(actualCategory, expectedCategory); + }); + it('should be right date format', () => { + browser.url('/item/11'); + + const actualDate = browser.getText('.media-heading small')[0]; + + assert(moment(actualDate, 'MMMM Do YYYY, h:m:s a', true).isValid()); + + }); + }); From e8531745e1af2a79e8fe0344944b0258927c77e2 Mon Sep 17 00:00:00 2001 From: ksenipetrova Date: Sat, 13 May 2017 19:16:26 +0500 Subject: [PATCH 2/2] =?UTF-8?q?=D0=B7=D0=B0=D0=B1=D1=8B=D0=BB=D0=B0(?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wdio.conf.js | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 wdio.conf.js diff --git a/wdio.conf.js b/wdio.conf.js new file mode 100644 index 0000000..0b38ee8 --- /dev/null +++ b/wdio.conf.js @@ -0,0 +1,41 @@ +exports.config = { + host: 'hub-cloud.browserstack.com', + port: 4444, + path: '/wd/hub', + user: 'xeniapeter1', + key: 'o7gL4AgWtLzsHnqGekue', + // + // ================== + // Specify Test Files + // ================== + // Define which test specs should run. The pattern is relative to the directory + // from which `wdio` was called. Notice that, if you are calling `wdio` from an + // NPM script (see https://docs.npmjs.com/cli/run-script) then the current working + // directory is where your package.json resides, so `wdio` will be called from there. + // + specs: [ + 'tests/**' + ], + + + // If you have trouble getting all important capabilities together, check out the + // Sauce Labs platform configurator - a great tool to configure your capabilities: + // https://docs.saucelabs.com/reference/platforms-configurator + // + capabilities: [ + { + browserName: 'chrome' + }, + { + browserName: 'firefox', + } + ], + + screenshotPath: 'shots', + + baseUrl: 'http://urfu-2016-testing.herokuapp.com/', + + waitforTimeout: 1000, + + framework: 'mocha' +}; \ No newline at end of file