protractor-firefox-support
This is custom implementation of Actions class functions
for e2e testing using Protractor framework in Firefox browser.
If you use it,
Installation
You can simply install it into your project using this command:
npm install protractor-firefox-support --save
Examples of usage
Here are examples of custom functions usage. Functions presented as separated modules which can be imported in test files:
here)
dragAndDrop (complete exampleconst support = require('protractor-firefox-support');
module.exports.performDnD = ({dragElmSelector = '.btn.btn-primary', dragElmIndex,
draggable = false} = {}) => {
const dropPoint = {x: 100, y: 100};
const options = {makeDraggable: draggable, dropLocation: dropPoint};
/**
* You can define dragElement index if there are more than
* one element with specified selector.
*/
(dragElmIndex) ? options.dragElemIndex = dragElmIndex : null;
/**
* Also you can pass selector instead of null, if you want to specify
* drop element.
*/
return browser.executeScript(support.dragAndDrop, dragElmSelector, null, options);
}
here)
openContextMenu(rightMouseClick, complete exampleconst support = require('protractor-firefox-support');
module.exports.openElementContextMenu = ({selector, elemIndex} = {}) => {
const options = {location: {x: 100, y: 100}};
/**
* If there are more elements which match specified selector, add elemIndex option.
* Property 'location' defines screen coordinates where context menu will be opened.
*/
(elemIndex) ? options.elemIndex = elemIndex : null;
return browser.executeScript(support.rightMouseBtnClick, selector, options);
}
here)
mouseUp (complete exampleconst support = require('protractor-firefox-support');
module.exports.mouseUp = (pointCoordinates = {x: 100, y: 100}) => {
return browser.executeScript(support.mouseUp, pointCoordinates);
}
here)
mouseMove (complete exampleconst support = require('protractor-firefox-support');
module.exports.mouseMove = (pointCoordinates = {x: 100, y: 100}) => {
return browser.executeScript(support.mouseMove, pointCoordinates);
}
here)
mouseDown (complete exampleconst support = require('protractor-firefox-support');
module.exports.mouseDown = ({selector, index} = {}) => {
/**
* If there are more elements which match specified selector, add elementIndex option.
*/
return browser.executeScript(support.mouseDown, {elementSelector: selector,
elementIndex: index});
}
here)
mouseClick (complete exampleconst support = require('protractor-firefox-support');
module.exports.mouseClick = ({elemSelector, point, tgtIndex} = {}) => {
const options = {};
(elemSelector) ? options.selector = elemSelector : null;
(point) ? options.point = point : null;
(tgtIndex) ? options.elementIndex = tgtIndex : null;
return browser.executeScript(support.mouseClick, options);
}
here)
changeInputText(beta, complete exampleconst support = require('protractor-firefox-support');
module.exports.changeInputText = (selector, text, {elemIndex} = {}) => {
/**
* If there are more elements which match specified selector, add elemIndex option.
*/
const options = {};
(elemIndex) ? options.elemIndex = elemIndex : null;
return browser.executeScript(support.changeInputText, selector, text, options);
}
here)
dispatchEvent(complete exampleconst support = require('protractor-firefox-support');
module.exports.dispatchEvent = ({selector, tgtIndex, eventType, isMouseEvent, eventArguments} = {}) => {
/**
* If there are more elements which match specified selector, add elementIndex option.
*/
const options = {selector, eventType, isMouseEvent, eventArguments};
(tgtIndex) ? options.elementIndex = tgtIndex : null;
return browser.executeScript(support.dispatchEvent, options);
}
Run tests
First of all you need to install necessary packages using next command:
npm run install-modules-tests
Then update webdriver-manager packages, start it and run tests:
npm run webdriver-update-windows
npm run webdriver-start-windows
npm run test-windows
for Windows or
npm run webdriver-update-linux
npm run webdriver-start-linux
npm run test-linux
for Linux/MacOS.