2

I want to streamline some browser automation scripts and bypass logging into the sandbox via the standard login page (with login and password).

Additionally, our automation scripts authenticate in the sandboxes via SOAP API (Enterprise/Tooling) using login + password + security token combination. This is used to create test data for browser tests via API. And from here, the automation test has a unique SessionId.

I noticed that if I set a browser's cookie sid=<SesssioIdFromSoapAPI> on the domain like https://sandboxDomain.sandbox.my.salesforce.com/ then I can skip the login page, and I log into the org/sandbox automatically.

The issue is that when the automation script needs to do something in the Setup, it gets the message...

We can't display this page because your browser blocks cross-domain cookies, but you can view this page in Salesforce Classic. Click here...

We can't display this page because your browser blocks cross-domain cookies, but you can view this page in Salesforce Classic. Click here to open this page in Salesforce Classic

... but if with the same browser with the same security settings, I log in via the login page with username + password, then I get the setup page with no problem...

SF Classic page is displayed correctly in the Setup

What should I do with cookies and/or authentication in automation tests to be able to see the Setup Pages?

4
  • As the test user, if you click on the lock icon in chrome > cookies > blocked, are there any that appear there? In an incognito window, I need to allow all of these to bypass this issue when I go to setup.
    – jmdohn
    Commented Feb 14, 2023 at 14:35
  • If you add "Sites that can always use cookies", with what appears under blocked, that should bypass the issue for you - type chrome://settings/cookies in your address bar.
    – jmdohn
    Commented Feb 14, 2023 at 14:44
  • @jmdohn there are no blocked cookies, and the browser is with "Allow all cookies" setting. I also tried to add everything related to my org via "Sites that can always use cookies". Same behavior. Commented Feb 14, 2023 at 19:27
  • From screen shot, it appears are in 2 different Sandboxes. Commented Jul 14, 2023 at 22:15

1 Answer 1

0

I'm not 100% sure about why it's throwing that error but only for certain parts of the site. Assuming you're using Chrome or a Chromium based browser, if not already done it's worth disabling web security.

To do that, start the browser with command line argument:

--disable-web-security

If you're using Cypress as your tooling, then you can configure this within the project (I assume other frameworks have a similar option).

import { defineConfig } from 'cypress'

export default defineConfig({
  chromeWebSecurity: false,
})

From the Cypress docs:

Setting chromeWebSecurity to false in Chrome-based browsers allows you to do the following:

  • Display insecure content
  • Navigate to any superdomain without cross-origin errors with or without cy.origin
  • Access cross-origin iframes that are embedded in your application

Cypress docs reference: https://docs.cypress.io/guides/guides/web-security.

1
  • Thank you for your suggestion! I tried, but the same results. Maybe it's got something to do with certain SF Setup pages that still run in the Classic mode. Commented Mar 13, 2023 at 8:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .