Protractor "window.angular is undefined" error with PhantomJS - phantomjs

All of my tests run without issue in Chrome or Firefox, but when Protractor is used, I'm getting the following error message:
/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/async/nexttick.js:41
goog.global.setTimeout(function() { throw exception; }, 0);
^
Error while waiting for Protractor to sync with the page: "window.angular is undefined. This could be either because this is a non-angular page or because your test involves client-side navigation, which can interfere with Protractor's bootstrapping. See http://git.io/v4gXM for details"
Going to http://git.io/v4gX results in a 404 error.
I'm encountering this same error message whether using
$ webdriver-manager start or
$ phantomjs --webdriver=9515
Using Protractor v3.0.0 and PhantomJS 2.1.1
I've seen similar queries for this issue:
Error while waiting for Protractor to sync with the page: "window.angular is undefined
The stated answer is we're trying to make phantomJS go to a page that isn't Angular, but that is definitely not our situation, as the page is Angular.
"window.angular is undefined." when using protractor for automated testing?
Here the supplied answer is use Protractor 3.0 and specify Jasmine2. Those are our currently supplied settings.
Protractor running tests on PhantomJS
States this issue was fixed in a prior Protractor release, but it appears to be back again.
I'm re-asking this question because the previous answers are now obsolete and irrelevant.

Related

Tests started failing with new version of testcafe where a http call to load a script has returned 500 Internal server error

I have testcafe tests working fine until version 1.14.0 and with the upgrade of the version to the latest (> 1.14.0), the tests have started to fail and the from console/network calls of the browser, I could see that one of the call to get the js file, has failed with 500 Internal server error and a blank white screen was loaded.
Note that the same works fine with testcafe <= 1.14.0 and the same call has went fine. And there was no other more information from the dev tools for the fail or there was no information in the application's logs as well.
The tests were run on chrome 92 with testcafe cli.

Is there a way to run nightwatch on Safari v12.1?

My mac auto-updated safari to v12.1, but now I can't run my nightwatch tests against safari. I just always get the error: "Request body does not contain required parameter 'capabilities'.". I think it's related to this issue: https://github.com/SeleniumHQ/selenium/issues/6431
Is there anything I can update or do inside of nightwatch to get the tests to run again?
Turns out safari made some huge breaking changes in v12. They removed support for the Selenium JSON wire protocol and now only support w3c WebDriver protocol. There isn't much you can do from a nightwatch config standpoint to fix this. Just try to find the w3c equivalent command for what you are trying to do and use that instead.
Ref: https://developer.apple.com/documentation/webkit/macos_webdriver_commands_for_safari_12_and_later

How to ignore JS errors in Selenium with PhantomJS?

I am working with a page that has some JS errors like TypeError: 'undefined' is not a function (evaluating 'q.apply(m,d)'), browsers seem to ignore these errors and the page functionality doesn't degrade, but PhantomJS throws an exception. How can I disable that? I've read how to ignore errors in phantomjs but I don't know how to do that with Selenium.
When I run my tests using PhantomJS 2.0 then I do not get the non-fatal javascript errors getting reported. However when I run with PhantomJS version 1.9.8 then I get the exact behavior that you describe. So simply upgrading the version of PhantomJS you are using to the latest may solve your problem.
Otherwise you can change the logging level of PhantomJS. I believe you can use code like this below where you instantiate the browser.
DesiredCapabilities caps = new DesiredCapabilities();
caps.setJavascriptEnabled(true);
caps.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, "--webdriver-loglevel=ERROR");
WebDriver driver = new PhantomJSDriver(caps);

PhantomJS ReferenceError: Can't find variable: performance

I am trying to run jasmine test cases using Karma and PhantomJS as the browser.
I get the following error:
ReferenceError: Can't find variable: performance' since I have performance APIs provided by Microsoft dev tools added in my code.
How to get rid of this error? Also, how can I prevent PhantomJS from giving any JavaScript errors when running unit test cases?
Performance timing API is now supported by PhantonJS 2 you can use the karma-phantomjs2-launcher Karma launcher https://www.npmjs.com/package/karma-phantomjs2-launcher.

Intern 2.0 test stuck after running client.html page

I have a local selenium server (2.42.2) running with Chromedriver and Firefox. It seems to get stuck after loading and running client.html. I can see that my functional suite code runs in node, far enough to execute the main body. Anything in registerSuite never gets called.
Here are the selenium logs:
http://pastebin.com/KKg5ycvW
I can see the browsers in the selenium sessions page, but they don't appear to be doing anything.
Try opening up a new browser window and paste in the url that you see in the existing selenium ones. Then open up dev tools and see what console errors you are getting.
Intern's runner seems to get stuck in an infinite loop if any uncaught javascript errors are thrown during unit tests if the 'reporter' hasn't been setup yet.
This has been raised as an issue in intern's github repository.