Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marketionist/protractor-numerator
This module adds readable numeration for elements in Protractor end-to-end testing framework
https://github.com/marketionist/protractor-numerator
e2e-tests elements-numeration-functions end-to-end javascript protractor protractor-numerator protractor-tests selenium
Last synced: 3 months ago
JSON representation
This module adds readable numeration for elements in Protractor end-to-end testing framework
- Host: GitHub
- URL: https://github.com/marketionist/protractor-numerator
- Owner: Marketionist
- License: mit
- Created: 2016-12-31T08:35:23.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2021-08-09T04:27:41.000Z (over 3 years ago)
- Last Synced: 2024-11-07T11:19:11.885Z (3 months ago)
- Topics: e2e-tests, elements-numeration-functions, end-to-end, javascript, protractor, protractor-numerator, protractor-tests, selenium
- Language: TypeScript
- Homepage:
- Size: 49.8 KB
- Stars: 9
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# protractor-numerator
[![No Maintenance Intended](http://unmaintained.tech/badge.svg)](http://unmaintained.tech/)
# This package is deprecated and will not be updated anymore as the Angular team announced that Protractor will be sunsetted at the end of 2022 - https://github.com/angular/protractor/issues/5502. Please consider switching to [testcafe-cucumber-steps](https://github.com/Marketionist/testcafe-cucumber-steps) or [webdriverio-cucumber-steps](https://github.com/Marketionist/webdriverio-cucumber-steps)
[![Build Status](https://travis-ci.org/Marketionist/protractor-numerator.svg?branch=master)](https://travis-ci.org/Marketionist/protractor-numerator)
[![npm version](https://img.shields.io/npm/v/protractor-numerator.svg)](https://www.npmjs.com/package/protractor-numerator)
[![NPM License](https://img.shields.io/npm/l/protractor-numerator.svg)](https://github.com/Marketionist/protractor-numerator/blob/master/LICENSE)This module gives you readable functions for getting elements by their numbers inside Protractor tests
## Supported versions
[Node.js](http://nodejs.org/):
- 6.x
- 7.x
- 8.x
- 9.x
- 10.x[Protractor](https://www.npmjs.com/package/protractor):
- 4.x
- 5.x## Installation
`npm install protractor-numerator --save-dev`## Importing and enabling
You can require protractor-numerator in `onPrepare` block inside
`protractor.config.js`. Here is a short config example:```javascript
exports.config = {
directConnect: true,framework: 'jasmine2',
specs: [
'spec.js'
],capabilities: {
browserName: 'chrome'
},onPrepare: function () {
global.numerator = require('protractor-numerator').numerator;
protractor.ElementArrayFinder.prototype = Object.assign(
protractor.ElementArrayFinder.prototype, numerator);
// Some other code that needs to be executed before all tests
}
};
```## Usage
For example let's take a small HTML list:```html
- First
- Second
- Third
- Fourth
- Fifth
- Sixth
- Seventh
- Eighth
- Ninth
- Tenth
- Eleventh
- Twelfth
- Thirteenth
- Fourteenth
- Fifteenth
- Sixteenth
- Seventeenth
- Eighteenth
- Nineteenth
- Twentieth
```
Inside your Protractor end-to-end tests you can get any element of this list like this:
```javascript
// Get all
let listItemSecond = element.all(by.css('.items li')).second();
let listItemThird = element.all(by.xpath('//li[ancestor::*[@class="items"]]')).third();
let listItemFourth = element.all(by.css('.items li')).fourth();
let listItemFifth = element.all(by.css('.items li')).fifth();
let listItemSixth = element.all(by.css('.items li')).sixth();
let listItemSeventh = element.all(by.css('.items li')).seventh();
let listItemEighth = element.all(by.css('.items li')).eighth();
let listItemNinth = element.all(by.css('.items li')).ninth();
let listItemTenth = element.all(by.css('.items li')).tenth();
let listItemEleventh = element.all(by.css('.items li')).eleventh();
let listItemTwelfth = element.all(by.css('.items li')).twelfth();
let listItemThirteenth = element.all(by.css('.items li')).thirteenth();
let listItemFourteenth = element.all(by.css('.items li')).fourteenth();
let listItemFifteenth = element.all(by.css('.items li')).fifteenth();
let listItemSixteenth = element.all(by.css('.items li')).sixteenth();
let listItemSeventeenth = element.all(by.css('.items li')).seventeenth();
let listItemEighteenth = element.all(by.css('.items li')).eighteenth();
let listItemNineteenth = element.all(by.css('.items li')).nineteenth();
let listItemTwentieth = element.all(by.css('.items li')).twentieth();
// Now you can do whatever you want with any element for example validate its text:
expect(listItemSecond.getText()).toBe('Second');
expect(listItemThird.getText()).toBe('Third');
expect(listItemFourth.getText()).toBe('Fourth');
expect(listItemFifth.getText()).toBe('Fifth');
expect(listItemSixth.getText()).toBe('Sixth');
expect(listItemSeventh.getText()).toBe('Seventh');
expect(listItemEighth.getText()).toBe('Eighth');
expect(listItemNinth.getText()).toBe('Ninth');
expect(listItemTenth.getText()).toBe('Tenth');
expect(listItemEleventh.getText()).toBe('Eleventh');
expect(listItemTwelfth.getText()).toBe('Twelfth');
expect(listItemThirteenth.getText()).toBe('Thirteenth');
expect(listItemFourteenth.getText()).toBe('Fourteenth');
expect(listItemFifteenth.getText()).toBe('Fifteenth');
expect(listItemSixteenth.getText()).toBe('Sixteenth');
expect(listItemSeventeenth.getText()).toBe('Seventeenth');
expect(listItemEighteenth.getText()).toBe('Eighteenth');
expect(listItemNineteenth.getText()).toBe('Nineteenth');
expect(listItemTwentieth.getText()).toBe('Twentieth');
```
## Thanks
If this plugin was helpful for you, please give it a **★ Star** on
[Github](https://github.com/Marketionist/protractor-numerator)