Guest User

Untitled

a guest
Jun 20th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. <%# Make sure you ONLY include this code in RAILS_ENV=test or cucumber %>
  2. <%# Note: Selenium treats alert()s as kind of failed expectation. %>
  3. <script type="text/javascript">
  4. window.cucumberOriginalAlert = window.alert;
  5. window.cucumberErrors = [];
  6. window.onerror = function() {
  7. var args = []; // typical arguments are Message, File, Line#
  8. for (var i = 0; i < arguments.length; i++) {
  9. args.push(arguments[i]);
  10. }
  11. cucumberErrors.push(args.join(", "));
  12. if (!window.cucumberErrorReporter) {
  13. window.cucumberErrorReporter = setInterval(function() {
  14. // Wait for selenium to replace the alert function, or we'll cause a REAL alert (bad!)
  15. if (window.alert != window.cucumberOriginalAlert) {
  16. alert(cucumberErrors.join("\n"));
  17. clearInterval(window.cucumberErrorReporter);
  18. }
  19. }, 100);
  20. }
  21. };
  22. </script>
Add Comment
Please, Sign In to add comment