-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#9 #12
#9 #12
Changes from 16 commits
28c4711
74782fc
c2a9295
08a5e67
01f181f
e4dafdf
1a345b1
5698ae1
6b10bca
8564fa4
9f3ffc4
4f7eb0a
e3e9b5b
227def1
43e59cc
27deb8b
bf72ef1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ node_modules | |
.* | ||
!.travis.yml | ||
!.editorconfig | ||
!.eslintrc.json | ||
*.xml | ||
.settings | ||
downloads | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env bash | ||
|
||
#Run server in background | ||
node_modules/http-server/bin/http-server ./test/demo-app -p 9000 > /dev/null & | ||
server=$! | ||
#Run tests | ||
./node_modules/.bin/wdio test/wdio.conf.js | ||
#Kill server after run | ||
kill -9 ${server} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
'use strict' | ||
|
||
const fs = require('fs'); | ||
const files = fs.readdirSync('./src/steps'); | ||
const fs = require('fs') | ||
const files = fs.readdirSync('./src/steps') | ||
|
||
files.forEach((f) => { | ||
const path = `./src/steps/${f}` | ||
const fileSteps = require(path); | ||
const fileSteps = require(path) | ||
|
||
if (typeof fileSteps === 'function') { | ||
fileSteps.apply(this); | ||
fileSteps.apply(this) | ||
} | ||
}); | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
'use strict' | ||
|
||
/* eslint no-param-reassign: 0*/ | ||
/* eslint no-undef: 0 */ | ||
|
||
const { _r } = require('./utils') | ||
|
||
const dynamicId = '$dynamicId$' | ||
const regDynamicId = '\\$dynamicId\\$' | ||
|
||
// Can come from applysteps ?? | ||
const pageObject = '("[^"]+"\."[^"]+")' | ||
const pageObjectsParts = '^"([^"]+)"\."([^"]+)"$' | ||
const pageObject = '([a-zA-Z0-9_-]+ from [a-zA-Z0-9_-]+ page)' | ||
const pageObjectsParts = '^([a-zA-Z0-9_-]+) from ([a-zA-Z0-9_-]+) page$' | ||
|
||
const dictionaryObject = '("[^"]+"\."[^"]+"|"[^"]*")' | ||
const dictionaryObjectsParts = '^(?:"([^"]+)"\."([^"]+)"|"([^"]*)")$' | ||
const dictionaryObject = '([a-zA-Z0-9_-]+ from [a-zA-Z0-9_-]+ dictionary|"[^"]*")' | ||
const dictionaryObjectsParts = '^(?:([a-zA-Z0-9_-]+) from ([a-zA-Z0-9_-]+) dictionary|"([^"]*)")$' | ||
|
||
// Todo do we need this in csp-qa | ||
function injectInto(locator, injection) { | ||
|
@@ -34,64 +33,61 @@ function injectInto(locator, injection) { | |
const body = locator.replace(/\[[0-9]+\]$/, '') | ||
|
||
return injectInto(body, injection) + nums | ||
} else { | ||
// Locator ends with brackets, which contain some properties | ||
return locator.substring(0, locator.length - 1) + ' and ' + injection | ||
} | ||
} else { | ||
// Locator contains no brackets | ||
return locator + '[' + injection | ||
return locator.substring(0, locator.length - 1) + ' and ' + injection | ||
} | ||
return locator + '[' + injection | ||
} | ||
|
||
function parsePageObject(str) { | ||
function pageObjectGetter(str) { | ||
const match = _r(pageObjectsParts).exec(str) | ||
|
||
if (!match) { | ||
throw new Error(`Was unable to find Page Object for "${str}"`) | ||
} | ||
if (match[1]) { | ||
const page = match[1] | ||
const object = match[2] | ||
const page = match[2] | ||
const object = match[1] | ||
|
||
if (!this.pages[page]) { | ||
if (!pages[page]) { | ||
throw new Error(`"${page}" page is missing`) | ||
} | ||
if (!this.pages[page][object]) { | ||
if (!pages[page][object]) { | ||
throw new Error(`"${object}" page object is missing for the "${page}" page`) | ||
} | ||
return this.pages[page][object] | ||
return pages[page][object] | ||
} | ||
throw new Error(`Unknown Page Object type for "${str}"`) | ||
} | ||
|
||
function getPageObject(str) { | ||
const value = parsePageObject.call(this, str) | ||
const idValue = value.replace(_r(regDynamicId, 'g'), this.id) | ||
const pageObjectGetterFunc = objectsProcessor.pageObjectGetter || pageObjectGetter | ||
const value = pageObjectGetterFunc(str) | ||
const idValue = value.replace(_r(regDynamicId, 'g'), id.getId()) | ||
const injection = 'not(ancestor-or-self::*[contains(@style,"visibility: hidden;") ' + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's not remove semicolons from CSS |
||
'or contains(@style,"display: none;") or contains(@class,"x-hide-offsets")])'; | ||
'or contains(@style,"display: none") or contains(@class,"x-hide-offsets")])' | ||
const injectedvalue = injectInto(idValue, injection) | ||
|
||
return injectedvalue | ||
} | ||
|
||
function parseDictionaryObject(str) { | ||
function dicionaryGetter(str) { | ||
const match = _r(dictionaryObjectsParts).exec(str) | ||
|
||
if (!match) { | ||
throw new Error(`Was unable to find Dictionary Object type for "${str}"`) | ||
} | ||
if (match[1]) { | ||
const dictionary = match[1] | ||
const object = match[2] | ||
const dictionary = match[2] | ||
const object = match[1] | ||
|
||
if (!this.pages[dictionary]) { | ||
if (!pages[dictionary]) { | ||
throw new Error(`"${dictionary}" page is missing`) | ||
} | ||
if (!this.pages[dictionary][object]) { | ||
if (!pages[dictionary][object]) { | ||
throw new Error(`"${object}" page object is missing for the "${dictionary}" page`) | ||
} | ||
return this.pages[dictionary][object] | ||
return pages[dictionary][object] | ||
} | ||
if (match[3] !== undefined) { | ||
return match[3] | ||
|
@@ -100,8 +96,9 @@ function parseDictionaryObject(str) { | |
} | ||
|
||
function getDictionaryObject(str) { | ||
const value = parseDictionaryObject.call(this, str) | ||
const idValue = value.replace(_r(regDynamicId, 'g'), this.id) | ||
const dicionaryGetterFunc = objectsProcessor.dicionaryGetter || dicionaryGetter | ||
const value = dicionaryGetterFunc(str) | ||
const idValue = value.replace(_r(regDynamicId, 'g'), id.getId()) | ||
|
||
return idValue | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* eslint no-undef: 0 */ | ||
/* eslint new-cap: 0 */ | ||
|
||
const { defineSupportCode } = require('cucumber') | ||
const { pageObject, getPageObject } = require('../helpers/objects.processor') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets try to use no semicolons. |
||
const { _r } = require('../helpers/utils') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
module.exports = function () { | ||
defineSupportCode(({ Then }) => { | ||
|
||
Then(_r(`^${pageObject} should be present$`), (object) => { | ||
/** | ||
* The element should be present | ||
* @type {PageObject} | ||
*/ | ||
const locator = getPageObject(object) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets try to use no semicolons. |
||
|
||
browser.$(locator).waitForExist() | ||
}) | ||
|
||
}) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets try to use no semicolons. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>DEMO APP FOR THE WDIO-STEPS</title> | ||
<link rel="stylesheet" href="styles/styles.css"> | ||
<script src="inc/script.js"></script> | ||
</head> | ||
<body> | ||
<div id="header">Header</div> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
let e = {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets try to use no semicolons. |
||
|
||
e.txtHeader = '//*[@id="header"]' | ||
|
||
module.exports = e | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets try to use no semicolons. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we will remove this line, then any changes to
.eslintrc.json
will not be tracked by git - are we sure that it should not be tracked?