question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to check the redirect url ?

See original GitHub issue

Hi, I’ve just started looking at protractor for our single page angularjs app. I met a problem now. In our login page, we have a logo, and when you click it, it will redirect you to the homepage of the company, it’s not the same url as the app’s.

My code in it:

            element(by.id('Home')).click();
            ptor.sleep(10000); 
            var expectedUrl = ptor.getCurrentUrl();
            expect(expectedUrl).toEqual('www.globalpaymentsinc.com');

I believe it’s about the promise in Angular, sounds like getCurrentUrl will always get the promise Url, but not the redirect url, but I’m not sure how to fix it. I got the error from this code:

Failures:

  1) Login Page English Page should redirect to GPN worldwide homepage when clic
k the GPN logo
   Message:
     Error: Error while waiting for Protractor to sync with the page: {"message"
:"angular is not defined","stackTrace":[{"fileName":"https://www.globalpaymentsi
nc.com/worldwide.html line 68 > Function:4","lineNumber":5,"methodName":"anonymo
us/<"},{"fileName":"https://www.globalpaymentsinc.com/worldwide.html line 68 > F
unction:9","lineNumber":1,"methodName":"anonymous"},{"fileName":"https://www.glo
balpaymentsinc.com/worldwide.html:68","lineNumber":11,"methodName":"handleEvalua
teEvent"}]}
   Stacktrace:
     Error: Error while waiting for Protractor to sync with the page: {"message"
:"angular is not defined","stackTrace":[{"fileName":"https://www.globalpaymentsi
nc.com/worldwide.html line 68 > Function:4","lineNumber":5,"methodName":"anonymo
us/<"},{"fileName":"https://www.globalpaymentsinc.com/worldwide.html line 68 > F
unction:9","lineNumber":1,"methodName":"anonymous"},{"fileName":"https://www.glo
balpaymentsinc.com/worldwide.html:68","lineNumber":11,"methodName":"handleEvalua
teEvent"}]}

Could anyone help? Thank you in advance.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:5

github_iconTop GitHub Comments

4reactions
smahalingamcommented, Jul 31, 2014

Use this instead - browser.driver.getCurrentUrl() it works for Non-angular pages like login page.

1reaction
skullz03commented, Apr 14, 2018

What if this was not the login page and just another angular page? What would be the implementation to check if the user has landed on the correct page or not if I wanted use the URL to do this validation. Like say for example : user is on page 1, clicks on a link and lands on page 2- use the URL to validate if he has landed on page 2 or not. Here is the code, I but doesn’t seem to be working

let exURL  = http://angularjs.org

Then(/^the user should have landed on the Financial Advisors site$/, function(){
           return browser.driver.getCurrentUrl().then(function (actualUrl) {
            return this.chai.expect(actualURL).equal(exURL, "Error: Navigated to Incorrect URL");
       });
Read more comments on GitHub >

github_iconTop Results From Across the Web

Redirect Checker | Check your Statuscode 301 vs 302
add http:// or https:// on your URL. Redirect Checker Options: You what to check your redirect with a specific user-agent. Just select the...
Read more >
WhereGoes: Tiny URL Expander | Redirect Checker
When the link checker traces a link, the results display all the links that you are being redirected through including php redirects, htaccess...
Read more >
Redirect Checker | Check the redirection of URLs
Enter the domain in the given URL field. · Click the “Check Redirection” button. · The results will be displayed on your device...
Read more >
URL Redirection Checker - Geekflare Tools
This tool is designed to trace the URL's path with status code and headers. Simply put, it shows all the hops it takes...
Read more >
How to Find All URL Redirects - Small Business - Chron.com
You can use the Windows advanced search function to find all of your website files that contain a redirect function. The Windows advanced...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found