Created
August 4, 2017 07:55
-
-
Save dherges/8e98ac9925d38f2ab1442b862a562fdf to your computer and use it in GitHub Desktop.
Angular, Protractor, Cucumber
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
import { browser, by, element, until } from 'protractor'; | |
export class AppPage { | |
public navigateTo() { | |
return browser.get('/'); | |
} | |
public enterSearchInput(text: string) { | |
return element(by.css('input[aria-label="search"]')) | |
.sendKeys(text); | |
} | |
public getSearchResultItems() { | |
const condition = until.elementsLocated(by.css('.search-results .search-result-item')); | |
return browser.wait(condition, 5000); | |
} | |
} |
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
import { expect } from 'chai'; | |
import { defineSupportCode } from 'cucumber'; | |
import { AppPage } from './app.po'; | |
defineSupportCode(({Given, When, Then, Before}) => { | |
let app: AppPage; | |
Before(() => { | |
app = new AppPage(); | |
}); | |
Given('I am on the angular.io site', | |
() => app.navigateTo()); | |
When('I type "{term}" into the search input field', | |
(text: string) => app.enterSearchInput(text)); | |
Then('I should see some results in the search overlay', | |
() => app.getSearchResultItems() | |
.then(elems => expect(elems.length).to.be.greaterThan(0))); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment