If from a Protractor spec, I execute a script within browser.executeAsyncScript, how should I communicate that the script has indeed failed? Consider the following call to browser.executeAsyncScript:
browser.executeAsyncScript((callback) ->
# How do I communicate an error condition here!?
callback()
)
.then((data) ->
console.log("Browser async finished without errors: #{data}")
, (data) ->
console.log("Browser async finished with errors: #{data}")
)
What I want to happen is that the error callback to then is invoked. How do I do this?
From the webdriverjs doc:
driver.executeAsyncScript(function() {
var callback = arguments[arguments.length - 1];
var xhr = new XMLHttpRequest();
xhr.open("GET", "/resource/data.json", true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
callback(xhr.responseText);
}
}
xhr.send('');
}).then(function(str) {
console.log(JSON.parse(str)['food']);
});
So, it does not seem to have an error callback, but you can pass some arguments to the callback method. You can use it to propagate errors.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments