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()); + + }); + }); 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