Skip to content

Commit

Permalink
Merge pull request #113 from wvankuipers/feature/1.2.0
Browse files Browse the repository at this point in the history
Version 1.2.0
  • Loading branch information
wvankuipers committed Jul 12, 2017
2 parents ba5064e + 88a797b commit a2c43f2
Show file tree
Hide file tree
Showing 23 changed files with 4,108 additions and 109 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ branches:
- master
- /^greenkeeper/.*$/

script: "npm run-script test"
script: "yarn run test"

after_success:
- npm install -g codeclimate-test-reporter
- yarn install -g codeclimate-test-reporter
- CODECLIMATE_REPO_TOKEN=b087813d4296a775b39b1465f365d52e6e8f62c6ee3150392345b0911bd186ee codeclimate-test-reporter < coverage/lcov.info
29 changes: 25 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Changelog

## [1.2.0] - 2017-07-12
### Added
- Rules:
- [Given] `I expect that element "([^"]*)?" is( not)* empty$`

### Changed
- Switched to [Yarn]() for managing our packages
- Readme to reflect Yarn changes
- Updated dependencies
- Removed no longer needed dependencies Cucumber and Babel-jest
- Locked Webdriverio to 4.7.1 to make sure we don't upgrade before all deprecated functions will be fixed
- Removed specific element/inputfield requirement from checkContainsAnyText, checkContainsText and checkEqualsText check's (thanks [cheapsteak](https://github.com/cheapsteak))

### Fixed
- `checkCointainsText` now correctly checks if the given element actualy contains the given text (thanks [inspiraller](https://github.com/inspiraller))
- Removed unneeded sudo from `clean` script (thanks [l-hendriks](https://github.com/l-hendriks))
- ESLint error's after upgrading ESLint
- Resolved an issue with running `yarn run clean` in Bash (thanks [mondwan](https://github.com/mondwan))
- Fixed `^I expect that element "([^"]*)?" is( not)* empty$` then rule (thanks [stevezxu](https://github.com/stevezxu))


## [1.1.1] - 2017-03-03
### Added
- Requirements section to the readme
Expand All @@ -15,7 +36,7 @@


## [1.1.0] - 2017-01-14
### Added
### Added
- Changelog
- Unit-tests set-up using Jest
- Basic unit-tests for all Javascript code
Expand All @@ -26,12 +47,12 @@
- Favicon to the demo-app

### Changed
- Moved the boilerplate code from `test/` to `src/` to make clear it's the
- Moved the boilerplate code from `test/` to `src/` to make clear it's the
source of the project and separate if from the actual test code.
- ESLint configuration now matches ES6 `comma-dangle`
- Updated dependencies
- `babel-reset-2015`
- `babel-register`
- `babel-reset-2015`
- `babel-register`
- `wdio-phantomjs-service`
- `webdriverio`
- `wdio-cucumber-framework`
Expand Down
29 changes: 16 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ Boilerplate project to run WebdriverIO tests with [Cucumber](https://cucumber.io

## Requirements

- Node version 4 or higher
- Node version 6 or higher

Although this project works fine with NPM we recommend to use Yarn (>= 0.20.0) instead, due to its speed & solid dependency locking mechanism. To keep things simple we use yarn in this guide, but feel free to replace this with NPM if that is what you are using.

## Quick start

Expand All @@ -22,14 +24,14 @@ Choose one of the following options:

3. Clean the project (Optional):
- *On OSX/Linux:*
-- Run `npm run clean`
-- Run `yarn run clean`

- *On Windows:*
-- Remove the directories `/.git`, `/.github`, `/demo-app` & `/test`
-- Remove the files `.travis.yml`, `jest.json` & `wdio.BUILD.conf.js`
-- Remove all the demo features from the `/src/features` directory

4. Install the dependencies (`npm install` or `yarn install`)
4. Install the dependencies (`yarn install`)

Now you are ready to write your own features.

Expand Down Expand Up @@ -76,13 +78,13 @@ query after doing a search. As you can see, it is pretty simple and understandab
Start the local web server:

```sh
$ npm run-script local-webserver
$ yarn run local-webserver
```

To run your tests just call the [WDIO runner](http://webdriver.io/guide/testrunner/gettingstarted.html):

```sh
$ wdio
$ yarn run wdio
```

_please note_ The WDIO runner uses the configuration file `wdio.conf.js` by default.
Expand Down Expand Up @@ -117,14 +119,14 @@ Your environment-specific config file will get merged into the default config fi
To run a test in a specific environment just add the desired configuration file as the first parameter:

```sh
$ wdio wdio.STAGING.conf.js
$ yarn run wdio wdio.STAGING.conf.js
```

# Running single feature
Sometimes its useful to only execute a single feature file, to do so use the following command:

```sh
$ wdio --spec ./test/features/select.feature
$ yarn run wdio -- --spec ./test/features/select.feature
```


Expand All @@ -140,7 +142,7 @@ Feature: ...
To run only the tests with specific tag(s) use the `--tags=` parameter like so:

```sh
$ wdio --tags=@Tag,@AnotherTag
$ yarn run wdio -- --tags=@Tag,@AnotherTag
```

You can add multiple tags separated by a comma
Expand Down Expand Up @@ -205,8 +207,9 @@ Check out all predefined snippets. You can see how they get used in [`sampleSnip
- `there is (an|no) element "([^"]*)?" on the page` <br>Check if a element (does not) exist
- `the title is( not)* "([^"]*)?"` <br>Check the title of the current browser window/tab
- `the element "([^"]*)?" contains( not)* the same text as element "([^"]*)?"` <br>Compaire the text of two elements
- `the (element|inputfield) "([^"]*)?"( not)* contains the text "([^"]*)?"` <br>Check if a element contains the given text
- `the (element|inputfield) "([^"]*)?"( not)* contains any text` <br>Check if a element does not contain any text
- `the element "([^"]*)?"( not)* contains the text "([^"]*)?"` <br>Check if a element contains the given text
- `the element "([^"]*)?"( not)* contains any text` <br>Check if a element does not contain any text
- `the element "([^"]*)?" is( not)* empty` <br>Check if a element is empty
- `the page url is( not)* "([^"]*)?"` <br>Check the url of the current browser window/tab
- `the( css)* attribute "([^"]*)?" from element "([^"]*)?" is( not)* "([^"]*)?"` <br>Check the value of a element's (css) attribute
- `the cookie "([^"]*)?" contains( not)* the value "([^"]*)?"` <br>Check the value of a cookie
Expand All @@ -225,9 +228,9 @@ Check out all predefined snippets. You can see how they get used in [`sampleSnip
- `I expect that element "([^"]*)?" is( not)* within the viewport` <br>Check if a certain element is within the current viewport
- `I expect that element "([^"]*)?" does( not)* exist` <br>Check if a certain element exists
- `I expect that element "([^"]*)?"( not)* contains the same text as element "([^"]*)?"` <br>Compare the text of two elements
- `I expect that (element|inputfield) "([^"]*)?"( not)* contains the text "([^"]*)?"` <br>Check if a element or input field contains the given text
- `I expect that (element|inputfield) "([^"]*)?"( not)* contains any text` <br>Check if a element or input field contains any text
- `I expect that (element|inputfield) "([^"]*)?" is( not)* empty` <br>Check if a element or input field is empty
- `I expect that element "([^"]*)?"( not)* contains the text "([^"]*)?"` <br>Check if a element or input field contains the given text
- `I expect that element "([^"]*)?"( not)* contains any text` <br>Check if a element or input field contains any text
- `I expect that element "([^"]*)?" is( not)* empty` <br>Check if a element or input field is empty
- `I expect that the url is( not)* "([^"]*)?"` <br>Check if the the URL of the current browser window/tab is a certain string
- `I expect that the path is( not)* "([^"]*)?"` <br>Check if the path of the URL of the current browser window/tab is a certain string
- `I expect the url to( not)* contain "([^"]*)?"` <br>Check if the URL of the current browser window/tab contains a certain string
Expand Down
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "cucumber-boilerplate",
"version": "1.1.1",
"version": "1.2.0",
"description": "Boilerplate project to run WebdriverIO tests with Cucumber",
"homepage": "https://github.com/webdriverio/cucumber-boilerplate",
"scripts": {
"clean": "read -p \"Are you sure you want to clean the project? [y/n] \" -n 1 -r; if [[ $REPLY =~ ^[Yy]$ ]]; then sudo rm -R .git .github demo-app test .codeclimate.yml .travis.yml jest.json wdio.BUILD.conf.js src/features/**; fi",
"clean": "read -p \"Are you sure you want to clean the project? [y/n] \" REPLY; if [[ $REPLY =~ ^[Yy]$ ]]; then rm -R .git .github demo-app test .codeclimate.yml .travis.yml jest.json wdio.BUILD.conf.js src/features/**; fi",
"local-webserver": "http-server ./demo-app -s",
"test": "npm run test:validate && npm run test:unit && npm run test:features",
"test:features": "npm run-script local-webserver & (wdio wdio.BUILD.conf.js; wdio_ret=$?; kill $(lsof -t -i:8080); exit $wdio_ret)",
"test:features": "npm run local-webserver & (wdio wdio.BUILD.conf.js; wdio_ret=$?; kill $(lsof -t -i:8080); exit $wdio_ret)",
"test:unit": "jest --config=jest.json",
"test:validate": "eslint 'src/**/*.js' 'test/**/*.js!(setup.js)'"
},
Expand All @@ -25,25 +25,26 @@
"selenium"
],
"author": "Christian Bromann <christian@saucelabs.com>",
"contributors": [
"W. van Kuipers <github@pwnd.nl>"
],
"license": "MIT",
"dependencies": {
"babel-preset-es2015": "~6.24.0",
"babel-register": "~6.24.0",
"chai": "~4.1.0",
"cucumber": "~2.2.0",
"wdio-cucumber-framework": "~0.3.0",
"wdio-cucumber-framework": "~0.3.1",
"wdio-phantomjs-service": "~0.2.2",
"wdio-selenium-standalone-service": "~0.0.8",
"wdio-selenium-standalone-service": "~0.0.9",
"wdio-spec-reporter": "~0.1.0",
"webdriverio": "~4.8.0"
"webdriverio": "4.7.1"
},
"devDependencies": {
"babel-jest": "~20.0.0",
"babel-polyfill": "~6.23.0",
"eslint": "~4.2.0",
"eslint-config-airbnb-base": "~11.2.0",
"eslint-plugin-import": "~2.6.0",
"eslint-plugin-import": "~2.7.0",
"http-server": "~0.10.0",
"jest": "~20.0.0"
"jest": "~20.0.4"
}
}
2 changes: 1 addition & 1 deletion src/features/githubSearch.feature.pending
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Scenario: search for webdriverio repository
And I press "Space"
And I add "selenium" to the inputfield ".input-block"
When I submit the form "#search_form"
Then I expect that inputfield ".input-block" contains the text "webdriverio selenium"
Then I expect that element ".input-block" contains the text "webdriverio selenium"
And I expect that element ".repo-list-item:first-child > .repo-list-description" contains the text "Webdriver/Selenium 2.0 JavaScript bindings for Node.js"

Scenario: login with fake credentials
Expand Down
16 changes: 8 additions & 8 deletions src/features/inputfield.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ Feature: Test input fields on a page

Background:
Given I open the site "/"
Then I expect that inputfield "#testInput" not contains any text
Then I expect that element "#testInput" not contains any text

Scenario: Set the content of a input field
When I set "test" to the inputfield "#testInput"
Then I expect that inputfield "#testInput" contains any text
And I expect that inputfield "#testInput" contains the text "test"
Then I expect that element "#testInput" contains any text
And I expect that element "#testInput" contains the text "test"

Scenario: Add content to a input field
When I set "test" to the inputfield "#testInput"
Then I expect that inputfield "#testInput" contains any text
Then I expect that element "#testInput" contains any text
When I add " more tests" to the inputfield "#testInput"
Then I expect that inputfield "#testInput" contains the text "test more tests"
Then I expect that element "#testInput" contains the text "test more tests"

Scenario: Clear the content of a input field
When I set "test" to the inputfield "#testInput"
Then I expect that inputfield "#testInput" contains any text
And I expect that inputfield "#testInput" contains the text "test"
Then I expect that element "#testInput" contains any text
And I expect that element "#testInput" contains the text "test"
When I clear the inputfield "#testInput"
Then I expect that inputfield "#testInput" not contains any text
Then I expect that element "#testInput" not contains any text
25 changes: 25 additions & 0 deletions src/features/isEmpty.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Feature: Test input fields on a page
As a developer
I want to be able to test input fields on a certain page

Background:
Given I open the site "/"
Then I expect that element "#testInput" is empty

Scenario: Set the content of a input field
When I set "test" to the inputfield "#testInput"
Then I expect that element "#testInput" is not empty
And I expect that element "#testInput" contains the text "test"

Scenario: Add content to a input field
When I set "test" to the inputfield "#testInput"
Then I expect that element "#testInput" is not empty
When I add " more tests" to the inputfield "#testInput"
Then I expect that element "#testInput" contains the text "test more tests"

Scenario: Clear the content of a input field
When I set "test" to the inputfield "#testInput"
Then I expect that element "#testInput" is not empty
And I expect that element "#testInput" contains the text "test"
When I clear the inputfield "#testInput"
Then I expect that element "#testInput" is empty
22 changes: 11 additions & 11 deletions src/features/sampleSnippets.feature
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,27 @@ Feature: Sample Snippets test

Scenario: add value to an input element
Given I open the url "http://webdriverjs.christian-bromann.com/"
And the inputfield "//html/body/section/form/input[1]" not contains the text "abc"
And the element "//html/body/section/form/input[1]" not contains the text "abc"
When I add "bc" to the inputfield "//html/body/section/form/input[1]"
Then I expect that inputfield "//html/body/section/form/input[1]" contains the text "abc"
Then I expect that element "//html/body/section/form/input[1]" contains the text "abc"

Scenario: set value to an input element
Given I open the url "http://webdriverjs.christian-bromann.com/"
And the inputfield "//html/body/section/form/input[1]" not contains the text "bc"
And the element "//html/body/section/form/input[1]" not contains the text "bc"
When I set "bc" to the inputfield "//html/body/section/form/input[1]"
Then I expect that inputfield "//html/body/section/form/input[1]" contains the text "bc"
Then I expect that element "//html/body/section/form/input[1]" contains the text "bc"

Scenario: clear value of input element
Given I open the url "http://webdriverjs.christian-bromann.com/"
When I set "test" to the inputfield "//html/body/section/form/input[1]"
And I clear the inputfield "//html/body/section/form/input[1]"
Then I expect that inputfield "//html/body/section/form/input[1]" not contains any text
Then I expect that element "//html/body/section/form/input[1]" not contains any text

Scenario: drag n drop
Given I open the url "http://webdriverjs.christian-bromann.com/"
And the inputfield ".searchinput" not contains the text "Dropped!"
And the element ".searchinput" not contains the text "Dropped!"
When I drag element "#overlay" to element ".red"
Then I expect that inputfield ".searchinput" contains the text "Dropped!"
Then I expect that element ".searchinput" contains the text "Dropped!"

Scenario: submit form
Given I open the url "http://webdriverjs.christian-bromann.com/"
Expand Down Expand Up @@ -115,10 +115,10 @@ Feature: Sample Snippets test

Scenario: check input content
Given I open the url "http://webdriverjs.christian-bromann.com/"
And the inputfield "//html/body/section/form/input[1]" contains the text "a"
And the inputfield "//html/body/section/form/input[1]" not contains the text "aa"
Then I expect that inputfield "//html/body/section/form/input[1]" contains the text "a"
And I expect that inputfield "//html/body/section/form/input[1]" not contains the text "aa"
And the element "//html/body/section/form/input[1]" contains the text "a"
And the element "//html/body/section/form/input[1]" not contains the text "aa"
Then I expect that element "//html/body/section/form/input[1]" contains the text "a"
And I expect that element "//html/body/section/form/input[1]" not contains the text "aa"

Scenario: check attribut
Given I open the url "http://webdriverjs.christian-bromann.com/"
Expand Down
4 changes: 2 additions & 2 deletions src/features/textComparison.feature
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Feature: Test text contents of elements
Then I expect that element "#textDoesContainCucumber" contains the text "This element contains cucumber"

Scenario: Input containing different text
Then I expect that inputfield "#valueDoesNotContainCucumber" not contains the text "This input contains cucumber"
Then I expect that element "#valueDoesNotContainCucumber" not contains the text "This input contains cucumber"

Scenario: Input containing the same text
Then I expect that inputfield "#valueDoesContainCucumber" contains the text "This input contains cucumber"
Then I expect that element "#valueDoesContainCucumber" contains the text "This input contains cucumber"
4 changes: 2 additions & 2 deletions src/features/wait.feature
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Feature: Test waiting for actions
Then I wait on element "#waitForContainsTextElement" for 1000ms to contain a text

Scenario: Test if element to contain a value
Given the inputfield "#waitForContainsValueElement" not contains any text
Given the element "#waitForContainsValueElement" not contains any text
When I click on the button "#waitForContainsValueBtn"
Then I wait on element "#waitForContainsValueElement" for 1000ms to contain a value

Expand Down Expand Up @@ -89,7 +89,7 @@ Feature: Test waiting for actions
Scenario: Test if element to not contain a value
When I click on the button "#waitForContainsValueBtn"
And I pause for 1000ms
Then I expect that inputfield "#waitForContainsValueElement" contains any text
Then I expect that element "#waitForContainsValueElement" contains any text
When I click on the button "#waitForContainsValueBtn"
Then I wait on element "#waitForContainsValueElement" for 2000ms to not contain a value

Expand Down
12 changes: 9 additions & 3 deletions src/steps/given.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import checkContainsAnyText from '../support/check/checkContainsAnyText';
import checkIsEmpty from '../support/check/checkIsEmpty';
import checkContainsText from '../support/check/checkContainsText';
import checkCookieContent from '../support/check/checkCookieContent';
import checkCookieExists from '../support/check/checkCookieExists';
Expand Down Expand Up @@ -60,20 +61,25 @@ module.exports = function given() {
);

this.Given(
/^the (element|inputfield) "([^"]*)?"( not)* matches the text "([^"]*)?"$/,
/^the element "([^"]*)?"( not)* matches the text "([^"]*)?"$/,
checkEqualsText
);

this.Given(
/^the (element|inputfield) "([^"]*)?"( not)* contains the text "([^"]*)?"$/,
/^the element "([^"]*)?"( not)* contains the text "([^"]*)?"$/,
checkContainsText
);

this.Given(
/^the (element|inputfield) "([^"]*)?"( not)* contains any text$/,
/^the element "([^"]*)?"( not)* contains any text$/,
checkContainsAnyText
);

this.Given(
/^the element "([^"]*)?" is( not)* empty$/,
checkIsEmpty
);

this.Given(
/^the page url is( not)* "([^"]*)?"$/,
checkUrl
Expand Down

0 comments on commit a2c43f2

Please sign in to comment.