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

evaluate(func, args) does not seem to allow functions to be passed #95

Open
disophisis opened this issue Jan 8, 2018 · 1 comment
Open

Comments

@disophisis
Copy link

disophisis commented Jan 8, 2018

I've copied a client side script from protractor (waitforangular) and I am attempting to use it with chromy.

Here's a small snippet ( I don't know that the entire code is required)

let waitForAngular = function (rootSelector, callback) {
		console.log(callback);
		console.log(rootSelector);
		try {
			// Wait for both angular1 testability and angular2 testability.

			var testCallback = callback;

			// Wait for angular1 testability first and run waitForAngular2 as a callback
			var waitForAngular1 = function (callback) {

				if (window.angular) {

I call:

chromy.evaluate(waitForAngular, ['app-root', callback]));

in the case of this snippet, callback is an anonymous function that was declared earlier on.

callback seems to be converted to a boolean value by doing this. If I look at the output from the console log statements from the waitForAngular call, 'app-root' gets passed correctly and the callback will either be undefined or true.

Is there a way to pass a callback function to the waitForAngular function using evaluate?

@TechQuery
Copy link
Contributor

Chromy.prototype.evaluate() returns a Promise() object, so you can use Promise.prototype.then() or await keyword in ECMAScript 8.

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