Httpbackend not working with Protractor v5.0+
See original GitHub issue- Node Version: 6.9.0
- Protractor Version: 5.1.1
- Browser(s): Chrome
- Breaking Change
I have my protractor tests set up to use http-backend-proxy which uses httpbackend, and everything works fine with protractor version 4.0.14, but in version 5.0+ they fail with an InvalidElementState error.
- InvalidElementStateError: invalid element state: Failed to execute ‘querySelector’ on ‘Document’: The provided selector is empty. (Session info: chrome=57.0.2987.133) (Driver info: chromedriver=2.29.461585 (0be2cd95f834e9ee7c46bcc7cf405b483f5ae83b),platform=Mac OS X 10.11.4 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 13 milliseconds Build info: version: ‘3.4.0’, revision: ‘unknown’, time: ‘unknown’ System info: host: ‘…’<removed>…, ip: ‘…<removed>…’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.11.4’, java.version: ‘1.8.0_73’ Driver info: org.openqa.selenium.chrome.ChromeDriver Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.29.461585 (0be2cd95f834e9ee7c46bcc7cf405b483f5ae83b), userDataDir=/var/folders/sz/n9py2wkd6zdg7nl5_phn7r497yn6vr/T/.org.chromium.Chromium.Wk2KMZ}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=57.0.2987.133, platform=MAC, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=}] Session ID: 0a8f87dee00b4e60542806e0aa4e417e
Code that now fails:
httpBackend = new HttpBackend( browser );
httpBackend
.when('GET', this.URL + 'user/self')
.respond( function() {
return [200, $httpBackend.context.userSelf];
});
I tried updating it to the following, just to see if that would help at all, but it still fails with the same error:
httpBackend
.whenGET(this.URL + 'user/self')
.respond( function() {
return [200, {}];
});
Any advice would be greatly appreciated!! Thanks!
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Protractor version 5.0 Http-backend-proxy failing
I upgraded from protractor version 4.0.14 to version 5.0.0 and now my tests are failing. I use http-backend-proxy for mocking the backend. The ......
Read more >Protractor - Quick Guide - Tutorialspoint
Protractor - Quick Guide, This chapter gives you an introduction to Protractor, where you will learn about the origin of this testing framework...
Read more >AngularJS: Developer Guide: Migrating from Previous Versions
Applications that still use it should migrate to Protractor. Technically, it should also be possible to continue using an older version of the...
Read more >Upgrading from AngularJS to Angular
This decreases the initial bundle size of your application as you're not loading code your user doesn't need yet. You also need to...
Read more >Angular Unit and End-to-End Testing for Ionic App Components
For this reason, the goal of testing is not to verify that the code is correct but to find problems within the code....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Adding rootElement: ‘body’ to my config file does fix the issue!
To try to simplify the code to show you for repo, I put everything in the onPrepare here:
Do you have a simple angular site that I could point to? I can’t provide my app code for repo, but if you have an angular site that I could point to and set up to reproduce, I will do that.
Thanks again!!
This error:
InvalidElementStateError: invalid element state: Failed to execute 'querySelector' on 'Document': The provided selector is empty
is what you get if you calldocument.querySelector()
with an empty string.There is a bug where appRoot can be the empty string in some cases, but after looking through clientsidescripts.js, I don’t see a case where that would make it to a
document.querySelector()
call.Could you provide an example repro case? Also, a few questions:
by.cssContainingText
?