1

I'm using a baseUrl in the config file and some tests access links that have prepended/appended text to the same url that needs to be verified. How can I verify the clicked url while using the baseUrl?

Example:

baseurl: dev.test.com

Link to be verified

this-dev.test.com/#/1234

'this' will not change but the numeric values will. The environment will change in the baseUrl (dev vs staging, etc).

2

You can get the currently used baseUrl from the browser.params. Then, the only thing left is to properly match the url. For this, we can use a simple toContain() or a more granular toMatch() jasmine matchers (assuming you are using Jasmine test framework):

expect(browser.getCurrentUrl()).toContain(browser.params.baseUrl);

expect(browser.getCurrentUrl()).toMatch("this-" + browser.params.baseUrl + "/#/");

And, I am also assuming by the "clicked URL" you meant the current url - hence, the use of getCurrentUrl() method.

You may also need to tweak things a bit if your baseUrl contains the protocol part (http:// or https://).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.