Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect adds __ within directory path when experimentalSourceRewriting is on #7439

Closed
varunpradhan opened this issue May 21, 2020 · 12 comments · Fixed by #15995
Closed

Redirect adds __ within directory path when experimentalSourceRewriting is on #7439

varunpradhan opened this issue May 21, 2020 · 12 comments · Fixed by #15995
Labels
experiment: source rewriting Issues when using experimentalSourceRewriting type: bug

Comments

@varunpradhan
Copy link

varunpradhan commented May 21, 2020

Current behavior:

Current behavior:
When I login through the normal browser then I am able to log in.
But when running from cypress test runner the directory path is missing from URL.

The Cypress Test Runner redirects to: http://:8084/__/branchHome.html

image

I have added below after there was a comment on my previous same bug still it didn't worked.

The previous bug raised: #5569

image

My cypress.json file:

image

Desired behavior:

The Cypress Test Runner should redirect to : http://:8084//branchHome.html

Test code to reproduce

Below is the code:

cy.visit("http://<ip>:8084/<directory>")
cy.get("#login").click()
cy.get("input[value='Organization']").click()
cy.get("#username").type('<User name provided>')
cy.get("#pwd").type('<password provided>')
cy.get("#login").click()

Versions

Cypress Version : 4.6.0
Operating System: Windows 10
Browser : Chrome 81 / Electron 80

@jennifer-shehane
Copy link
Member

@varunpradhan Thanks for opening an issue.

Do you have any idea what in your application initiates the redirect to the branchHome page? Typically we've seen this issue when the application under test is changing the route in some manual way. Some previous examples were:

  • Setting location, location.href, calling location.replace, location.assign
  • Calling window.top or window.parent
  • Calling into window.frames, window.parent.frames or other frames
  • Having an integrity attribute on script resources.

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label May 21, 2020
@varunpradhan
Copy link
Author

@jennifer-shehane yes it uses location.href

@flotwig
Copy link
Contributor

flotwig commented May 21, 2020

I think this might be happening because the current version of experimentalNetworkStubbing only works on JS served from the current origin. JS served from other origins is not yet intercepted.

Is the script that does the location.href change served from the same domain that you originally cy.visited?

@varunpradhan
Copy link
Author

@flotwig yes it is from the same domain.

@jennifer-shehane jennifer-shehane changed the title Redirect adds __ within directory path in 4.6.0 still Redirect adds __ within directory path when experimentalSourceRewriting is on May 22, 2020
@jennifer-shehane jennifer-shehane added the experiment: source rewriting Issues when using experimentalSourceRewriting label May 22, 2020
@flotwig
Copy link
Contributor

flotwig commented May 22, 2020

Can you share the source code that is doing the location.href change please?

@varunpradhan
Copy link
Author

varunpradhan commented May 22, 2020

@flotwig Below is the source code that is doing the location.href change:

function navigate(url) {
  try {
    window.location.href = url;
  } catch (e) {
    alert(e + "url===>" + url);
  }
}

We are using a relative URL.
Can anyone also suggest what approach in source code will work my cypress test? I will pass on the feedback to my developers.

@flotwig
Copy link
Contributor

flotwig commented May 22, 2020

@varunpradhan the issue occurs when setting href to a relative path, so if you could use an absolute URL instead of relative, that would avoid the bug

@varunpradhan
Copy link
Author

@flotwig I have forwarded the feedback to development team. Thank you for the suggestion. But I don't think they will change this anytime soon.
Till that time will be waiting for this bug to be resolved.

@cypress-bot cypress-bot bot added stage: needs investigating Someone from Cypress needs to look at this and removed stage: needs information Not enough info to reproduce the issue labels May 29, 2020
@gcoombe
Copy link

gcoombe commented Nov 17, 2020

We're seeing the same. Are there any other workarounds? For us the setting of location.href is inside a framework so it's not something we can update. Unfortunately this means that Cypress just won't work for a large part of our site.

@flotwig does this mean code served via cdn won't be intercepted? For example if we visit alpha.zenefits.com and our js is served via cdn.zenefits.com it's not expected to work?

I think this might be happening because the current version of experimentalNetworkStubbing only works on JS served from the current origin. JS served from other origins is not yet intercepted.

@gcoombe
Copy link

gcoombe commented Dec 2, 2020

Is there any timeline on when these redirecting to __ issues will be addressed? It's causing us significant pain and means we can't write tests for a number of high traffic areas of our app. Would be great to know if this is on the roadmap as we plan our future usage of Cypress.

@cypress-bot cypress-bot bot added stage: work in progress and removed stage: needs investigating Someone from Cypress needs to look at this labels Apr 15, 2021
@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review stage: work in progress and removed stage: work in progress stage: needs review The PR code is done & tested, needs review labels Apr 26, 2021
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels May 7, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented May 7, 2021

The code for this is done in cypress-io/cypress#15995, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented May 10, 2021

Released in 7.3.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v7.3.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators May 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
experiment: source rewriting Issues when using experimentalSourceRewriting type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants