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

Cy.Url Doesnt support UTF-8 charset #17399

Closed
arifozkan opened this issue Jul 19, 2021 · 4 comments · Fixed by #17930
Closed

Cy.Url Doesnt support UTF-8 charset #17399

arifozkan opened this issue Jul 19, 2021 · 4 comments · Fixed by #17930

Comments

@arifozkan
Copy link

arifozkan commented Jul 19, 2021

Current behavior

I want to test Url to check the page right or not. But whenever url contains unique chars such as (ä, ö," " ) it errors. Is there any solution?

The first one is cy.url().The second one is original url. Url changes inside cypress test.
image

My solution is

if(arrLost[2].raceLocation.includes("ä")){
  trackName.replaceAll("ä", "%C3%A4")
}
else if(arrLost[2].raceLocation.includes(" ")){
  trackName.replaceAll(" ", "%20")
}
else if(arrLost[2].raceLocation.includes(" ")){
  trackName.replaceAll("´", "%C2%B4")
}
cy.url().should("contain",trackName).wait(2000)

But this is waste of time. Thanks...

Desired behavior

No response

Test code to reproduce

if (arrLost[2].raceLocation.includes("ä")) {
  trackName.replaceAll("ä", "%C3%A4")
}
else if (arrLost[2].raceLocation.includes(" ")) {
  trackName.replaceAll(" ", "%20")
}
else if (arrLost[2].raceLocation.includes(" ")) {
  trackName.replaceAll("´", "%C2%B4")
}
cy.url().should("contain", trackName).wait(2000)

Cypress Version

6.9.0

Other

No response

@sainthkh
Copy link
Contributor

Sorry for the late reply.

How about using decodeURI function like below?

it('t', () => {
  cy.visit('https://mozilla.org/?x=шеллы')

  cy.url().then((url) => {
    expect(decodeURI(url)).to.contain('шеллы')
  })
})

@sainthkh sainthkh added stage: awaiting response Potential fix was proposed; awaiting response existing workaround labels Aug 16, 2021
@sainthkh
Copy link
Contributor

sainthkh commented Aug 16, 2021

@jennifer-shehane

I believe there are 2 solutions for this issue:

What do you think is better?

@cypress-bot cypress-bot bot added stage: work in progress There is an open PR for this issue [WIP] stage: needs review The PR code is done & tested, needs review and removed stage: awaiting response Potential fix was proposed; awaiting response stage: work in progress There is an open PR for this issue [WIP] labels Aug 30, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Aug 31, 2021

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

@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Aug 31, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Sep 13, 2021

Released in 8.4.0.

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

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Sep 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants