promod
v1.22.0
Published
Library for automation testing
Downloads
6,267
Maintainers
Readme
Usage with selenium engine
const {seleniumWD} = require('promod');
const {$, $$, getDriver, browser} = seleniumWD;
;(async () => {
const searchInput = $('input[name="q"]');
const sections = $$('section');
await getDriver({seleniumAddress: 'http://localhost:4444/wd/hub'}, browser);
await browser.get('https://www.npmjs.com/');
await searchInput.sendKeys(`promod${browser.Key.ENTER}`);
console.log(await sections.get(0).$('a').getText());
})()
Usage with playwright engine (only for local execution)
const {playwrightWD} = require('promod');
const {$, $$, getDriver, browser} = playwrightWD;
;(async () => {
const searchInput = $('input[name="q"]');
const sections = $$('section');
await getDriver(browser);
await browser.get('https://www.npmjs.com/');
await searchInput.sendKeys(`promod${browser.Key.ENTER}`);
console.log(await sections.get(0).$('a').getText());
})()
Transition from protractor to promod. Mocha example.
"test": "protractor ./protractor.conf.js"
"test": "mocha $(find specs -name '*.spec.*') --file ./mocha.hooks.js --timeout 500000"
Where:
$(find specs -name '*.spec.*')
spec files
--file ./mocha.hooks.js
mocha hooks file
mocha.hooks.js example
const {config} = require('./protractor.conf.js');
const {seleniumWD} = require('promod');
before(async function() {
/**
* onPrepare - protractor part
* rest - other config data
*/
const {onPrepare, ...rest} = config;
const {getDriver, browser, $, $$} = seleniumWD;
await getDriver(rest, browser);
// i am not a big fan of global object usage, but if it is suitable for you, just add API to global
global.browser = browser;
global.$ = $;
global.$$ = $$;
if (onPrepare) {
await onPrepare();
}
});
after(async function() {
await global.browser.quit();
});
"update:driver": "webdriver-manager update"
"update:driver": "selenium-standalone install"
Improvement plan
- [ ] Add documentation - in progress
- [x] Add playwright integration - in progress
- [ ] Add test runner - in progress
- [ ] Add logger - in progress