Does cypress support sales force - cypress

I tried to logon to SF application using cypress script
it is logging on but the moment it logs on cypress runner in left pane disappearing and test is not running further
it("should sales force page is open", () => {
cy.visit("https://***-digital--fpqa.my.salesforce.com/")
cy.get('#username').type('murali.naidu#******')
cy.get('#password').type('*****')
cy.get('#Login').click()
cy.wait(1000)
cy.url().should('include','sSSA')
})**strong text**

Related

Cypress cy.origin() & Google sign in not working

I'm trying to login to our site which uses Auth0 and Google Sign in but I'm having issues with cy.origin it's behaving different in each browser, none of which is letting me log in. This is my test:
import { loginPage } from '../../page-objects/login-page'
describe('Login Tests', () => {
beforeEach(() => {
loginPage.visit()
})
it('GoogleLogin', () => {
// Click google sign in button - On My Base URL
cy.get("a[data-testid='googleSignInButton']").click()
// I'm now on an Auth0 Page where I click the Google Sign In Button
cy.get("a[class='auth0-lock-social-button auth0-lock-social-big-button']").click()
// Now I am on the accounts.google.com domain
cy.origin('https://accounts.google.com', () => {
// enter email on accounts.google.com
cy.get("input[type='email']").type('myemail#gmail.com')
// click next button seen on accounts.google.com page
cy.get(
"button[class='VfPpkd-LgbsSe VfPpkd-LgbsSe-OWXEXe-k8QpJ VfPpkd-LgbsSe-OWXEXe-dgl2Hf nCP5yc AjY5Oe DuMIQc LQeN7 qIypjc TrZEUc lw1w4b']",
).click()
})
})
})
The issues I'm seeing are:
In Chrome once I get to accounts.google.com the test times out with "Timed out after waiting 60000ms for your remote page to load on origin(s)"
In Firefox the test times out with the same error as on Chrome but on the Auth0 page instead of accounts.goole.com
In Electron when I click the Google Sign in button on Auth0 I'm taken to accounts.google.com but a message is displayed "403. That’s an error. We're sorry, but you do not have access to this page. That’s all we know."
In Edge I can get to accounts.google.com and enter "myemail#gmail.com" and click the next button but then I see a message "This browser or app may not be secure.
Try using a different browser. If you’re already using a supported browser, you can try again to sign in." with a Try again button.
Four browsers are all reacting differently and not one is letting me actually login, can anyone see what I've done wrong?

Before/After spec not working as expected

In my Cypress configuration I have a before and after spec:
on('before:spec', () => {
console.log('before spec');
});
on('after:spec', () => {
console.log('after spec');
});
When I do cypress:run I see the before and after logged with each spec. But when I run cypress:open I see a the before spec when I open the Cypress client, not when I open the spec. The after spec is also not logged when the test is finished, but rather when the Cypress client is closed.
From the documentation:
The after:spec event fires after a spec file is run. When running
cypress via cypress open, the event will fire when the browser closes.
and
When running via cypress open, the after:spec event only fires if the experimentalInteractiveRunEvents flag is enabled.

Cypress Javascript Automation: Getting 500 error when uploading using Cypress

I am trying to automate uploading a picture on a website. I can manually upload fine. But when I do it using Cypress and node module cypress-file-upload, I get 500 server error.
I have import 'cypress-file-upload'; in commands.js file. I have
Cypress.on('uncaught:exception', (err, runnable) => {
return false;
});
I get application threw an error if I do not have this exception code.
This is what my code looks like for upload
cy.fixture('settings.JPG').then(fileContent => {
cy.get('[id="xyz"]').attachFile({
fileContent: fileContent.toString(),
fileName: 'settings.JPG',
mimeType: 'image/png'
});
});
As I look at browser where cypress is running, I can see, file is being attached near the Choose file field. But as soon Cypress clicks on the submit button, it throws 500 error
If I go to Cypress view pane and click on the submit button, it throws 500 error again
But if I click on the choose file and select the same file and then click on Submit button, then I do not get 500 error and it works.
Can anyone point out why I am getting 500 error? and what can I do to get past this? Thanks a bunch in advance.
Try to replace your mimeType as a image/jpg.

How to enable browser notifications using Cypress

I am using Cypress for e2e testing and the site I am testing requires to have the notification permission granted.
For manual testing, I go to chrome preferences->Privacy and Security->Site Settings->Notifications and set the site url to 'Allow'
But how do I do this on Cypress ?
To do this on Cypress you need the index.html and then you can do this first test to confirm that the browser support notifications:
/// <reference types="Cypress" />
describe('Browser notifications', () => {
it('are supported by the test browser', () => {
cy.visit('index.html')
cy.window().should('have.property', 'Notification').should('be.a', 'function')
})
})
If you enable notifications from Cypress itself, you will see a popup if you click "Notify me!" button.
The rest of the tests stubs Notification constructor to avoid popups
You can use the cypress-browser-permissions
plugin.

Cypress seems to have stalled

I'm new to cypress and love the way it is architected. However, I seem to have run into a problem early on for a very simple thing that I'm trying to do.
My workflow is:
1) Visit the site
2) Enter username and password
3) On the next screen, type a number and press submit,
4) On the next screen, select a value from a dropdown and press enter.
5) I get to the landing page of my website.
Cypress works totally fine till step 4). It seems to stall at step 5. The test runner suddenly stalls and without warning or error, shows
"Whoops, there is no test to run."
From here, when I click the "View All Tests" button, it takes me to the runner tool. There I see the indication that something is still running in the background. I tried waiting for more than 10 minutes but nothing happens until I click on the "Stop" action.
How do I debug this? Can I see what is happening via any log etc?
There could even be something wrong with my website as well, but without any log information, I'm unable to proceed further. Any help is appreciated.
To provide more context, I don't think this is a timeout based issue as if that were the case, cypress did report to me about this and stopped. I then increased the timeout.
My spec file
describe('My first test', function() {
it('Visits home page', function() {
cy.visit('https://mywebsite.com:5800', {timeout: 400000}, {pageLoadTimeout: 400000}, {defaultCommandTimeout: 400000})
cy.get('#USERNAME').type('myusername')
cy.get('#PASSWORD').type('mypassword')
cy.get('#loginbutton').click()
cy.get('#SOMELEMENT_WHERE_I_TYPE_A_UNIQUE_NUMBER').type('8056')
cy.get('#loginbutton').click()
cy.get('#loginbutton').click()
})
})
Thanks.
If you run DEBUG=cypress:* cypress open from the terminal when initially opening Cypress, there will be more debug log information printed there while you run your tests.
Also, it's always a good idea to search the issues for the project to see if anyone else has had this happen.
For some reason, the Cypress automation gets into a state where it thinks that you have no spec file. All Cypress does to determine this is to see if there is a location.hash defined on the main window -> where it usually says https://localhost:2020/__/#tests/integration/my_spec.js.
Likely this is due to security mechanisms in the app that prevent your application from being run within an iframe (which is how Cypress runs all applications under test). Maybe in your application code it is something like:
if (top !== self) {
top.location.href = self.location.href;
}
You can simply disable these checks while testing or in Cypress you can add to your test file (or a support file to have it work on every test file):
Cypress.on('window:before:load', (win) => {
Object.defineProperty(win, 'self', {
get: () => {
return window.top
}
})
})
I had the same issue. Usually this is related to the page moving out of the parent and can be solved by invoking the attribute and changing it to the current page.
cy.get('.approved-content .no-auto-submit').invoke('attr', 'target', '_self');

Resources