Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot find module "../lib/retry" #68

Open
FreddieXue opened this issue Jan 24, 2020 · 1 comment
Open

cannot find module "../lib/retry" #68

FreddieXue opened this issue Jan 24, 2020 · 1 comment

Comments

@FreddieXue
Copy link

Hi

I followed the instructions and tried to install protractor-retry. I intergrated the codes regarding retry but it doesnt work.

Here is my config, (config.capabilities is in another file)

var retry = require('../lib/retry');

export const config: Config = {
framework: 'jasmine',
specs: applicationConfig[application].specs,
jasmineNodeOpts: { defaultTimeoutInterval: 3000000 },
allScriptsTimeout: 1200000,
directConnect: !seleniumAddress,
seleniumAddress: seleniumAddress,
chromeDriver: !seleniumAddress ? require('chromedriver').path : null,

SELENIUM_PROMISE_MANAGER: false,
onCleanUp: async (results) => {
    await retry.onCleanUp(results);
},
onPrepare: async () => {
	await retry.onPrepare();
    require('jasmine-expect');
    browser.ignoreSynchronization = true;
	jasmine.getEnv().addReporter(htmlReporter.getJasmine2Reporter());
	jasmine.getEnv().addReporter(junitReporter);
	jasmine.getEnv().addReporter(specReporter);

	await browser
		.manage()
		.window()
		.setSize(windowSizeX, windowSizeY);
	browser.ignoreSynchronization = false;

	await browser.waitForAngularEnabled(false);

	const loginPage = new LoginPage();
	const header = new Header();

	await browser.get(applicationUrl, 10000);

	//login
	var rd = Math.random()*10000;
	await browser.sleep(rd);
	if (applicationConfig[application].isGateKeeperProtected) {
		await loginPage.login(testUserEmail, testUserPassword);
		if (!(await header.isLoggedIn())) {
			log.error('Not logged in!');
		}
	}
	
	//await browser.waitForAngularEnabled(true);

	config.baseUrl = applicationUrl + '/';
	browser.baseUrl = applicationUrl;
	log.info(application.toUpperCase() + ' Url: ' + browser.baseUrl);
	/*
	add custom locators 'TestID'
	*/
	by.addLocator('testid', function (value, parentElement) {
		parentElement = parentElement || document;
		var nodes = parentElement.querySelectorAll('[testid]');
		return Array.prototype.filter.call(nodes, function (node) {
			return (node.getAttribute('testid') === value);
		});
	});

	by.addLocator('formcontrolname', function (value, parentElement) {
		parentElement = parentElement || document;
		var nodes = parentElement.querySelectorAll('[formcontrolname]');
		return Array.prototype.filter.call(nodes, function (node) {
			return (node.getAttribute('formcontrolname') === value);
		});
	});

	by.addLocator('value', function (xvalue, parentElement) {
		parentElement = parentElement || document;
		var nodes = parentElement.querySelectorAll('[value]');
		return Array.prototype.filter.call(nodes, function (node) {
			return (node.getAttribute('value') === xvalue);
		});
	});

	by.addLocator('formgroupname', function (value, parentElement) {
		parentElement = parentElement || document;
		var nodes = parentElement.querySelectorAll('[formgroupname]');
		return Array.prototype.filter.call(nodes, function (node) {
			return (node.getAttribute('formgroupname') === value);
		});
	});

	by.addLocator('type', function (value, parentElement) {
		parentElement = parentElement || document;
		var nodes = parentElement.querySelectorAll('[type]');
		return Array.prototype.filter.call(nodes, function (node) {
			return (node.getAttribute('type') === value);
		});
	});

	by.addLocator('stationtype', function (value, parentElement) {
		parentElement = parentElement || document;
		var nodes = parentElement.querySelectorAll('[stationtype]');
		return Array.prototype.filter.call(nodes, function (node) {
			return (node.getAttribute('stationtype') === value);
		});
	});

	by.addLocator('routerlink', function (value, parentElement) {
		parentElement = parentElement || document;
		var nodes = parentElement.querySelectorAll('[routerlink]');
		return Array.prototype.filter.call(nodes, function (node) {
			return (node.getAttribute('routerlink') === value);
		});
	});

	by.addLocator('title', function (value, parentElement) {
		parentElement = parentElement || document;
		var nodes = parentElement.querySelectorAll('[title]');
		return Array.prototype.filter.call(nodes, function (node) {
			return (node.getAttribute('title') === value);
		});
	});

	by.addLocator('aria-label', function (value, parentElement) {
		parentElement = parentElement || document;
		var nodes = parentElement.querySelectorAll('[aria-label]');
		return Array.prototype.filter.call(nodes, function (node) {
			return (node.getAttribute('aria-label') === value);
		});
	});
},
afterLaunch : async () => {
	return await retry.afterLaunch(2); // number of retries ( default is 2 )
}

};

@anilreddy
Copy link

anilreddy commented Jun 17, 2020

@FreddieXue

// remove this below line
var retry = require('../lib/retry'); 
// and add this instead
var retry = require('protractor-retry').retry;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants