2

I was developing a feature that redirects users to profiles on various platforms. And to test this, I wrote the following code using the newly released cy.origin yesterday.

cy.origin('www.example.com', () => {
    cy.visit('/username')
})

However, github and twitter were successfully redirected, but linkedin was not the only one.

error image

I think the problem is caused by the user agent. Is there any way to solve this problem?

sunwoo Lee
  • 71
  • 1
  • 6
  • It works ok for me. `cy.origin('https://www.linkedin.com', () => { cy.visit('/login') })` - no errors. – Fody Apr 26 '22 at 05:30
  • @Fody It works to me too. but user's profile is not work, try changing `cy.visit('/login')` to `cy.visit('/in/sunwoo0706')` – sunwoo Lee Apr 26 '22 at 05:51
  • Yeah I did that too - got a bad status code but with `{failOnStatusCode: false}` I get redirected. Didn't get your error. – Fody Apr 26 '22 at 06:11
  • it works to me !!, But I don't think `{failOnStatusCode: false}` is a good way to test. If the URL is not valid and returns 404, the test will be passed. – sunwoo Lee Apr 26 '22 at 06:51
  • 1
    You don't have a choice, unless you work at Linkedin and can change the server. – Fody Apr 26 '22 at 07:14
  • So, looks like it's nothing to do with `cy.origin()` - this would happen if you just did a simple `cy.visit()` – user16695029 Apr 27 '22 at 09:39
  • @user16695029 I understand that cypress needs to use `cy.origin()` to visit different origin. Is it different from what I know? – sunwoo Lee Apr 28 '22 at 07:20

1 Answers1

1

For the record,

cy.origin('https://www.linkedin.com', () => {
  cy.visit('/in/sunwoo0706', {failOnStatusCode: false})  // redirects to login page
})
Fody
  • 23,754
  • 3
  • 20
  • 37