expect to test url #fragment with protractor and jasmine

Viewed 4188

I'm trying to use protractor (with jasmine) to do some functional tests for my web application, and one of problem I came across is:

how to check what is the current hash (#fragment) in my url?

for example using, browser.get('/') it should navigate to http://localhost:8000/#/ url ... where #/ is the url #fragment (the hash) that is used by angular when html5 mode is not enabled.

the browser.getCurrentUrl() will return the absolute url since http:// and not just the fragment which I want to test.

is there a way to test this case in a correct way?

I would expect to do something like this:

browser.get('/');
expect(browser.getCurrentUrlFragment()).toBe('#/');

browser.get('/user/');
expect(browser.getCurrentUrlFragment()).toBe('#/user');

is that possible?

thank you.

2 Answers
Related