dabusking
dabusking

Reputation: 13

URL manipulation in protractor

I am trying to write a protractor test that allows me to log in to the application. Currently, when i authorize my account, oauth generates an authentication token, and gives it to me in a https format. As of right now, the only way i can access the application is to simply take the "s" out of the https in the URL, and i will be able to access the app.

an example of the URL that is returned when i authorize my account is :

https://localhost:3000/#/authorize?oauth_token=escgPGm9si5N

All i want to do is have protractor take the secure connection URL, delete the s in https, and keep everything else and use that to keep moving. Since the authentication token changes every time, i cant store it as a variable. I am pretty sure I will have to use browser.getCurrentUrl, but i don't know what to do next. Any help will be greatly appreciated

Upvotes: 1

Views: 185

Answers (1)

wap300
wap300

Reputation: 2770

If you only need to throw the "s" out of the https, you'll be good with below:

browser.getCurrentUrl().then(function (url) {
    //here the url is just a string!
    var correctUrl = url.replace("https", "http");

    //now you can do whatever with the correct url, like go to it
    browser.get(correctUrl);
});

Please let know if you need anything more.

Upvotes: 1

Related Questions