-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
96a61d7
commit fa39a28
Showing
57 changed files
with
1,141 additions
and
1,073 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
## Setup | ||
|
||
* Install [Chrome](https://www.google.com/chrome/) | ||
* Install [Node.js](https://nodejs.org) (6 or higher) | ||
* Run `npm install --save-dev cucumber selenium-webdriver@3.0.1 chromedriver@2.25.1` | ||
* Add the following files | ||
|
||
|
@@ -21,48 +22,52 @@ | |
// features/support/world.js | ||
require('chromedriver') | ||
var seleniumWebdriver = require('selenium-webdriver'); | ||
var {defineSupportCode} = require('cucumber'); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
aslakhellesoy
Contributor
|
||
function CustomWorld() { | ||
this.driver = new seleniumWebdriver.Builder() | ||
.forBrowser('chrome') | ||
.build(); | ||
} | ||
module.exports = function() { | ||
this.World = CustomWorld; | ||
}; | ||
defineSupportCode(function({setWorldConstructor}) { | ||
setWorldConstructor(CustomWorld) | ||
}) | ||
``` | ||
```javascript | ||
// features/step_definitions/hooks.js | ||
module.exports = function () { | ||
this.After(function() { | ||
var {defineSupportCode} = require('cucumber'); | ||
defineSupportCode(function({After}) { | ||
After(function() { | ||
return this.driver.quit(); | ||
}); | ||
}; | ||
}); | ||
``` | ||
```javascript | ||
// features/step_definitions/browser_steps.js | ||
var seleniumWebdriver = require('selenium-webdriver'); | ||
var {defineSupportCode} = require('cucumber'); | ||
module.exports = function () { | ||
this.Given('I am on the Cucumber.js GitHub repository', function() { | ||
defineSupportCode(function({Given, When, Then}) { | ||
Given('I am on the Cucumber.js GitHub repository', function() { | ||
return this.driver.get('https://github.com/cucumber/cucumber-js/tree/master'); | ||
}); | ||
this.When('I click on {stringInDoubleQuotes}', function (text) { | ||
When('I click on {stringInDoubleQuotes}', function (text) { | ||
return this.driver.findElement({linkText: text}).then(function(element) { | ||
return element.click(); | ||
}); | ||
}); | ||
this.Then('I should see {stringInDoubleQuotes}', function (text) { | ||
Then('I should see {stringInDoubleQuotes}', function (text) { | ||
var xpath = "//*[contains(text(),'" + text + "')]"; | ||
var condition = seleniumWebdriver.until.elementLocated({xpath: xpath}); | ||
return this.driver.wait(condition, 5000); | ||
}); | ||
}; | ||
}); | ||
``` | ||
* Run `./node_modules/.bin/cucumber-js` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Can we do named imports in node?