Is it possible to check the location path? I'm new to AngularJS and I'm learning with a book that describes ngScenario. This package is deprecated and I'm trying to update the described test to protractor.
E.g.
expect(browser().location().path()).toEqual('/books');
becomes:
expect(browser.getCurrentUrl()).toEqual('http://localhost:8080/#/books');
But I'd like to avoid http://localhost:8080/
.
Just use the power of jasmine matchers:
expect(browser.getCurrentUrl()).toMatch(/\/#\/books$/); // /#/books at the end of url
expect(browser.getCurrentUrl()).toEndWith("/#/books");
expect(browser.getCurrentUrl()).toContain("/#/books");
where toEndWith()
is coming from an awesome jasmine-matchers
library.
Or, if you want an exact match, get the base URL:
expect(browser.getCurrentUrl()).toEqual(browser.baseUrl + "/#/books");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With