Protractor: How should I propagate an error from within browser.executeAsync?

aknuds1

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?

Bastien Caudan

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Protractor: How should I propagate an error from within browser.executeAsync?

From Dev

How do I invoke protractor from within an express node server?

From Dev

Should I use browser or ptor = protractor.getInstance()?

From Dev

How to pass variable from browser to Protractor

From Dev

How could I start executables from within a modern browser?

From Dev

how do I print a Yahoo email from within the Chrome browser?

From Dev

Can I access the document or window objects from within a protractor test?

From Dev

Protractor: How to access the `ElementFinder` class from within a test

From Dev

How to return child elements from within parent element in Protractor

From Dev

How do I propagate updates to all items within a Colectica DDI item graph?

From Dev

How do I interpret PostgreSQL error messages from within Go?

From Dev

How should I copy a keyspace within a cluster

From Dev

How can I get a line height from font size within browser?

From Dev

How can I get a line height from font size within browser?

From Dev

How should I refer to inner enums (defined within an entity) from a JPQL query using Hibernate?

From Dev

Can I run Jasmine + Protractor tests in a browser?

From Dev

Access window object / browser scope from protractor

From Dev

Protractor, when should I use then() after a click()

From Dev

Access inner element from within an element in protractor

From Dev

should I assign a variable or return variable from getText() promise of Element in protractor

From Dev

How to propagate nested error in Q .then() callback

From Dev

How to propagate an error code outside a terminal?

From Dev

How can I make a POST request from a Protractor test?

From Dev

With Protractor, how can I return a boolean from a function

From Dev

How can I get the number of children from an element with protractor?

From Dev

On a protractor helper function, how can I know if browser.get was ever called?

From Dev

How can I propagate an exception thrown from an asynchronous function to an awaiting async void function?

From Dev

How to propagate property change notifications of objects within collections

From Dev

How to make permanent changes to a website's CSS from within the browser?

Related Related

  1. 1

    Protractor: How should I propagate an error from within browser.executeAsync?

  2. 2

    How do I invoke protractor from within an express node server?

  3. 3

    Should I use browser or ptor = protractor.getInstance()?

  4. 4

    How to pass variable from browser to Protractor

  5. 5

    How could I start executables from within a modern browser?

  6. 6

    how do I print a Yahoo email from within the Chrome browser?

  7. 7

    Can I access the document or window objects from within a protractor test?

  8. 8

    Protractor: How to access the `ElementFinder` class from within a test

  9. 9

    How to return child elements from within parent element in Protractor

  10. 10

    How do I propagate updates to all items within a Colectica DDI item graph?

  11. 11

    How do I interpret PostgreSQL error messages from within Go?

  12. 12

    How should I copy a keyspace within a cluster

  13. 13

    How can I get a line height from font size within browser?

  14. 14

    How can I get a line height from font size within browser?

  15. 15

    How should I refer to inner enums (defined within an entity) from a JPQL query using Hibernate?

  16. 16

    Can I run Jasmine + Protractor tests in a browser?

  17. 17

    Access window object / browser scope from protractor

  18. 18

    Protractor, when should I use then() after a click()

  19. 19

    Access inner element from within an element in protractor

  20. 20

    should I assign a variable or return variable from getText() promise of Element in protractor

  21. 21

    How to propagate nested error in Q .then() callback

  22. 22

    How to propagate an error code outside a terminal?

  23. 23

    How can I make a POST request from a Protractor test?

  24. 24

    With Protractor, how can I return a boolean from a function

  25. 25

    How can I get the number of children from an element with protractor?

  26. 26

    On a protractor helper function, how can I know if browser.get was ever called?

  27. 27

    How can I propagate an exception thrown from an asynchronous function to an awaiting async void function?

  28. 28

    How to propagate property change notifications of objects within collections

  29. 29

    How to make permanent changes to a website's CSS from within the browser?

HotTag

Archive