Created
June 19, 2015 12:26
-
-
Save raphaelrodrigues/fa85de1292d74a7af835 to your computer and use it in GitHub Desktop.
Cucumber Example Minium
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
# language: en | |
# ------------------------------------------------------------------------------ | |
Feature: Search results in Google | |
Scenario: Search something in google | |
Given I'm at http://www.google.com/ncr | |
When I search for minium github | |
Then a link for https://github.com/viltgroup/minium is displayed | |
Scenario Outline: Search something in google (results in a JSON file) | |
Given I'm at http://www.google.com/ncr | |
When I search for <search_query> | |
Then links corresponding to <search_query> are displayed | |
Examples: | |
| search_query | | |
| Minium Github | | |
| Selenium | |
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
Given(/^I'm at (.*)$/, function (url) { | |
browser.get(url); | |
}); | |
When(/^I search for (.*)$/, function (query) { | |
var searchbox = $(":input").withName("q"); | |
var button = $("button").withAttr("aria-label", "Google Search"); | |
searchbox.fill(query); | |
button.click(); | |
}); | |
Then(/^a link for (.*) is displayed$/, function (linkUrl) { | |
var links = $("a"); | |
var link = links.withAttr("data-href", linkUrl).add(links.withAttr("href", linkUrl)); | |
expect(link).to.have.size(1); | |
}); | |
Then(/^links corresponding to (.*) are displayed$/, function (query) { | |
var links = $("a"); | |
var linkUrls = config.searches[query]; | |
expect(linkUrls).to.exist(); | |
linkUrls.forEach(function (linkUrl) { | |
var link = links.withAttr("data-href", linkUrl).add(links.withAttr("href", linkUrl)); | |
expect(link).to.have.size(1); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment