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

After the SalesForce Login it shows the "Whoops, there is no test to run" #2367

Closed
AlanGDC opened this issue Aug 17, 2018 · 70 comments · Fixed by #25307
Closed

After the SalesForce Login it shows the "Whoops, there is no test to run" #2367

AlanGDC opened this issue Aug 17, 2018 · 70 comments · Fixed by #25307
Labels

Comments

@AlanGDC
Copy link

AlanGDC commented Aug 17, 2018

Current behavior:

  • My Cypress file has only three elements; username, pass and login button:
describe('First SF Test', function() {
  it('Login SF', function() {
    cy.visit('https://iunigo--testing.lightning.force.com/') 
                                                           
    cy.get('.username')
      .type('services@*****')

    cy.get('.password')
      .type('******')

  
    cy.get('#Login')
      .click()
  })
})
  • After Cypress complete the fields and click login, the screen shows "Whoops, there is no test to run" and stop the test.

  • I asked this issue in https://gitter.im/cypress-io/cypress, and someone told me that its because Cypress doesn't allow you to change domains.

  • I tried this, I used my browser, and login as a real human would do, then I copied the url that the authentication generated into the Cypress test to "pre-load" the domain after the login change it, as shown below;

describe('First SF Test', function() {
  it('Login SF', function() {
    **cy.visit('https://iunigo--testing.lightning.force.com/lightning/r/Policy__c/a0F0m000001uIO6EAM/view')** 
                                                           
    cy.get('.username')
      .type('services@*****')
    cy.get('.password')
      .type('******')
    cy.get('#Login')
      .click()
  })
})
  • I this case, the message "Whoops, there is no test to run" appears inmediatly after running Cypress.

Desired behavior:

After login Cypress redirect me to SalesForce dashboard.

Steps to reproduce:

Versions

Cypress version 3.0.3, Mac Os, Google Chrome

@jennifer-shehane jennifer-shehane added the stage: needs investigating Someone from Cypress needs to look at this label Aug 18, 2018
@malindapw
Copy link

I have the same problem to test the Salesforce site. Is there are any workaround? thanks

@johncblandii
Copy link

This is SF clickjacking protection. It forces the login form action to run on _top.

@kuceb
Copy link
Contributor

kuceb commented Nov 15, 2018

@johncblandii is right. At some point, probably at a login attempt, there was a script like window.top.location = ... which broke out of the cypress AUT iframe. This is part of the reason we don't recommend testing 3rd party sites, because this is unavoidable

so you should disable the anti-clickjacking code if you're trying to test that page, and if you don't own the code on that page, work around it by logging in via an API or query params in the url

@kuceb kuceb closed this as completed Nov 15, 2018
@simonmagabe
Copy link

Anyone with a workaround to log in to Salesforce please help me I'm completely stuck. Thanks.

@simonmagabe
Copy link

@bkucera Could you please help how to disable the anti-clickjacking code. Thanks.

@jennifer-shehane jennifer-shehane removed the stage: needs investigating Someone from Cypress needs to look at this label Dec 4, 2018
@kuceb
Copy link
Contributor

kuceb commented Dec 5, 2018

@simonmagabe if you control the source code, find the code that calls window.location or window.top and put a flag around it to disable it in a testing/staging/dev environment.

if you don't control the source code, you can't. This is why we suggest not to test pages you don't control. Instead, try logging in programmatically with cy.request to bypass that UI

@johncblandii
Copy link

Turning off anti-clickjacking doesn't work, @bkucera.

Cypress should look at moving beyond the iframe so it can be used for more than "we own all of the code" scenarios. To help understand why this keeps being an issue, Salesforce testing isn't about testing their sign in. It is about signing into their system and testing custom apps built on the Salesforce stack. By not using an iframe in TestCafe, I signed in easily on SF and wrote tests quickly.

@simonmagabe that is something you have to get Salesforce to do.

@jennifer-shehane jennifer-shehane added the topic: 😳 whoops there is no test to run Error msg: "Whoops there is no test to run" label Jan 8, 2019
@torcu
Copy link

torcu commented Apr 30, 2019

I am having the same issue. Is this iframe problem also happening in headless mode?

@kuceb
Copy link
Contributor

kuceb commented Apr 30, 2019

@johncblandii yes this is the downside of Iframing the app, without rewriting all the AST in the proxy (which is possible).

Current Workaround

We recommend using the Salesforce API to generate a user session, by using cy.request(), which will automatically set cookies for you, and yield you tokens that belong in localStorage or similar session storage.

@eric-r-feng
Copy link

@bkucera I'm currently running into the same issue. I'm new to Cypress and was wondering if you could explain how this issue could be bypassed.

@johncblandii
Copy link

@bkucera, we ditched Cypress long ago for this reason and lack of other browser support. I couldn't make the case for Cypress with these issues.

Making an API request to auth was clunky for us when better solutions existed on other test platforms.

I hope it continues to improve. It is so close to being great.

@kristianwilliamssagecom
Copy link

kristianwilliamssagecom commented Aug 1, 2019

I don't think the current workaround works. I can create the session using cy.request, but when doing cy.visit to go to https://xxxxxx.lightning.force.com/lightning/setup/SetupOneHome/home I still get the whoops message

Here is my test code

cy.request({
  method: 'POST',
  url: 'https://xxxxxx.my.salesforce.com/services/oauth2/token',
  form: true,
  body:'grant_type=password&client_id=MY_ID&client_secret=MY_SECRET&username=MY_USERNAME&password=MY_PASSWORD'
});  

cy.visit('https://xxxxxx.my.salesforce.com/lightning/setup/SetupOneHome/home')

note the post url isn't to test.salesforce.com but my scratch org domain name
Has anyone been able to get this to work?

@tstutson
Copy link

^ seeing the same issue

@josh-mckever
Copy link

Is there no fix for this? This issue was posted a year ago and its ongoing. Please provide some follow up as we are still having this problem

@jennifer-shehane jennifer-shehane added the stage: wontfix Cypress does not regard this as an issue or will not implement this feature label Aug 26, 2019
@jennifer-shehane
Copy link
Member

Current recommended workaround is in this comment: #2367 (comment)

We haven't written out a specific example of exactly every piece of code to write to work around this. So, any suggestions from people who have gotten this working is appreciated.

@kristianwilliamssagecom
Copy link

kristianwilliamssagecom commented Aug 27, 2019

@jennifer-shehane I tried the workaround using the code I posted above, which sends a request that works and returns an access token that we can verify is valid, but we noticed that cy.request does not save the cookie automatically, so then we tried to save the cookie ourselves using;

cy.setCookie('sid', 'access_token')

which does save a cookie but doesn't allow us to bypass the login as suggested we assume this is because setCookie doesn't seem to save any of the cookie options, lastly we tried to set the cookie options as below but then it no longer saves the cookie at all.

cy.setCookie('sid', 'access_token', {
    path:'/',
    httpOnly: true,
    secure: false,
    domain: 'domain_name'
  });

I have not tried any of the above on any other site other than for trying to login to our salesforce scratch org, so I'm not suggesting these methods are broken but I may be using cy.request or cy.setCookie incorrectly or maybe its some salesforce magic that's not allowing it to work. I would say, however, that if what I am doing is correct that the workaround doesn't work.

The actual app we want to test isn't built using salesforce so we are just going to mock the backend and test the UI standalone but it would be nice to be able to run the tests by going through salesforce so if anyone has any luck please let me know as there is very little information out there where people use cypress for testing Salesforce apps.

@bassolini
Copy link

bassolini commented Aug 29, 2019

Hey guys,
I found a way to pass that, if you put the username + password in your cy.visit() it works, you can get through the login page.

Example:

cy.visit("https://test.salesforce.com/un=test.user%40workspace.com&pw=your_password&startURL=%2F001")

the %40 is just the encoded format of @, replacing test.user@workspace.com with test.user%40workspace.com

It worked for me, hope it helps :)

@kristianwilliamssagecom
Copy link

kristianwilliamssagecom commented Aug 30, 2019

Hey guys,
I found a way to pass that, if you put the username + password in your cy.visit() it works, you can get through the login page.

Example:
cy.visit("https://test.salesforce.com/un=test.user%40workspace.com&pw=your_password&startURL=%2F001")

the %40 is just the encoded format of @, replacing test.user@workspace.com with test.user%40workspace.com

It worked for me, hope it helps :)

Thanks for this, but unfortunately doesn't work for me, when I try it through cypress I get the message CypressError: cy.visit() failed trying to load:, and I get a URL No Longer Exists page when I try this manually, I did a (very) little bit of research and it seems this has been deprecated by salesforce or its specifically for a type of org, glad it works for you though. Do you have a source for where you found this solution? it may lead to other options.

@kristianwilliamssagecom
Copy link

kristianwilliamssagecom commented Aug 30, 2019

Hey guys,
I found a way to pass that, if you put the username + password in your cy.visit() it works, you can get through the login page.
Example:
cy.visit("https://test.salesforce.com/un=test.user%40workspace.com&pw=your_password&startURL=%2F001")
the %40 is just the encoded format of @, replacing test.user@workspace.com with test.user%40workspace.com
It worked for me, hope it helps :)

Thanks for this, but unfortunately doesn't work for me, when I try it through cypress I get the message "CypressError: cy.visit() failed trying to load:", and I get a "URL No Longer Exists" page when I try this manually, I did a (very) little bit of research and it seems this has been deprecated by salesforce or its specifically for a type of org, glad it works for you though. Do you have a source for where you found this solution? it may lead to other options.

So I managed to get this to work manually by using the following URL

https://test.salesforce.com/login.jsp?un=user%40scratch.com&pw=thePassword123

oddly when doing it manually if you try it a second time in the same session it complains the password is wrong.

When trying with cypress I get a security error

SecurityError: Blocked a frame with origin "https://DOMAIN_NAME.documentforce.com" from accessing a cross-origin frame.

Which looks like it can be fixed by setting chromeWebSecurity: false however after doing that I now get

Refused to display 'LOGIN_URL' in a frame because it set 'X-Frame-Options' to 'deny'. 

which I'm guessing is a salesforce security option denying this. is there something you @bassolini have set in your org to allow this to work?

@bassolini
Copy link

Hey guys,
I found a way to pass that, if you put the username + password in your cy.visit() it works, you can get through the login page.
Example:
cy.visit("https://test.salesforce.com/un=test.user%40workspace.com&pw=your_password&startURL=%2F001")
the %40 is just the encoded format of @, replacing test.user@workspace.com with test.user%40workspace.com
It worked for me, hope it helps :)

Thanks for this, but unfortunately doesn't work for me, when I try it through cypress I get the message "CypressError: cy.visit() failed trying to load:", and I get a "URL No Longer Exists" page when I try this manually, I did a (very) little bit of research and it seems this has been deprecated by salesforce or its specifically for a type of org, glad it works for you though. Do you have a source for where you found this solution? it may lead to other options.

Hey, sorry small mistake, I missed the ? before the un=

https://test.salesforce.com/?un=test.user%40workspace.com&pw=your_password&startURL=%2F001

@kuceb
Copy link
Contributor

kuceb commented Sep 3, 2019

I'll re-open this for visibility, since it is an issue many users will run into and it is possible we may be able to fix this in the futue

@kuceb kuceb reopened this Sep 3, 2019
@simonmagabe
Copy link

simonmagabe commented Sep 3, 2019 via email

@psvillanueva
Copy link

I have work workaround.

Previously, we logged in via GET request:

cy.request({
  method: 'GET',
  qs: {
    pw: 'pa$$word',
    startURL: '/home',
    un: 'username@example.com',
  },
  url: 'https://login.salesforce.com',
})

Now we can logged in via POST request: https://help.salesforce.com/s/articleView?id=000363298

cy
  .request({
    body: {
      display: 'page',
      hasRememberUn: 'true',
      height: '1080',
      local: '',
      locale: '',
      login: '',
      loginType: '',
      loginURL: '',
      lt: 'standard',
      oauth_callback: '',
      oauth_token: '',
      pw: 'pa$$word',
      qs: '',
      serverid: '',
      startURL: '',
      un: 'username@example.com',
      useSecure: 'true',
      username: 'username@example.com',
      width: '2560',
    },
    form: true,
    method: 'POST',
    url: 'https://login.salesforce.com',
  })

Please, try it.

This worked for me. Thanks!

@lucascruz9494
Copy link

lucascruz9494 commented Aug 24, 2022

I had the same problem as almost everyone I think...
What I think I discovered is that the problem of the left panel disappearing occurs when you are redirected to this link "https://yourWorkPlaceUrl.lightning.force.com/one/one.app"
(you have to replace yourWorkPlaceUrl , obviously)
After you are redirected to this link, you are redirected to your desired link, but for some reason the left panel closes ( maybe because a previous url was not within the baseUrl or the .app , I really don't know)

So what I have was 2 work arounds :
1 - If you can login by cy.request() or something like this to bypass the "manual" login, you do that and visit the url I mentioned before
2 - If you can't bypass the login it is going to be a really bad work around but you need to create one test one only for the manual login so the cypress can preserve cookies , localStorage, or anything that needs to keep you logged...
Once you are logged you can close the test, rename it with "it.skip" so it won't try to log you again and then you can visit the url I mentioned before on the other tests...

so If access that link first , it won't close the left panel , some developer needs to investigate this

@SebOpalinski
Copy link

Has anyone tried these approaches on Winter '23 and got it working? I can use these on the previous release but now Salesforce just hangs showing the Winter '23 logo.

@jpatil14
Copy link

jpatil14 commented Sep 9, 2022

We are too experiencing the same issue. We used to login to QA env sandbox using sessionid and everything was working fine untill the recent release of SF. However since recent release page is not moving ahead and only displaying 23 logo.

I could see some log details as below in cypress runner which were not there before recent release of SF. is anybody getting anything out of it?
image

@jpatil14
Copy link

@jennifer-shehane Could you please update us on this if you can? i believe this is a global issue

@AtofStryker
Copy link
Contributor

Hey all! Have any of you tried the experimentalModifyObstructiveThirdPartyCode option to see if this fixes some of the click jacking / frame busting you are seeing with SalesForce?

@jpatil14
Copy link

jpatil14 commented Oct 7, 2022

@AtofStryker Yeah tried it but no success

@jeanabanto
Copy link

image

Any update on this? I am also getting stuck on the winter '23 loading page. Everything was working fine until recent release.

@tit
Copy link

tit commented Oct 17, 2022

@jeanabanto It is global problem (see #23958).
So far, no one has managed to find a working solution...

@AtofStryker
Copy link
Contributor

Hey all. We appreciate your patience on getting this issue resolved. The "Whoops, there is no test to run" needs to have the experimentalModifyObstructiveThirdPartyCode enabled to fix, plus leveraging the new experimental flag mentioned in #24290 (comment) to fix the b.Store is not a constructor issues. This will be available in Cypress 12.4.0!

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jan 24, 2023

Released in 12.4.0.

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

@cypress-bot cypress-bot bot removed the stage: new label Jan 24, 2023
@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Jan 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.