cypress

Cypress login using request method

China☆狼群 提交于 2019-12-11 15:50:20
问题 I register & login a user, however, when in my test I navigate to a page behind authentication, Cypress fails & takes me back to the login page. From the looks of it, the before function is successfully executed (as verified by the API log). Here is my code: describe("Dashboard page", () => { before(() => { cy.fixture("authUserRegistrationDetail.json").then(userDetail => { cy.fixture("authUserLoginDetail.json").then(userLoginDetail => { cy.visit("http://localhost:3000/login"); cy.get("

How can I catch unexpected error messages during Cypress test execution?

别来无恙 提交于 2019-12-11 15:46:13
问题 I am using Cypress and iziToast (http://izitoast.marcelodolce.com/) to run some tests on a web application. I spotted an unexpected error message whilst running it locally. I was able to catch it by adding the following cy.toast statement to my code: cy.get(tabbedPanelControlsTitle) .should('have.value', 'Teams') .click(); // this is causing the following unexpected error cy.toast({ type: 'Error', code: 'E1527360562', }); I was able to get it to fail here using the following: cy.wrap({ toast:

Is it possible to write a script that would intercept HTTP requests on HAproxy with the purpose of appending client side pki certificates?

与世无争的帅哥 提交于 2019-12-11 15:45:04
问题 I am a test engineer that is new to the game - 3 years experience - so sorry if I am not coming across as a technical wizard :) Would ask that you be patient with me, I'm also here to learn so happy to be corrected/ridiculed. Due to the sensitivity of our applications, we are working with client side PKI certificates. These need to be loaded by the user into the browser if the application can be accessed. I was wondering if it would be possible that instead of having to import test

ESLint: 'cy' is not defined (Cypress)

允我心安 提交于 2019-12-11 14:39:39
问题 I've just started using Cypress with my React Typescript project. I've gotten some simple tests to run: describe('settings page', () => { beforeEach(() => { cy.visit('http://localhost:3000') }); it('starts in a waiting state, with no settings.', () => { cy.contains('Waiting for settings...') }); it('shows settings once settings are received', () => { const state = cy.window().its('store').invoke('getState') console.log(state) // different question: how do I get this to be the state and not a

Cypress tests continuously run XHR posts when visiting localhost (running vue.js)

一个人想着一个人 提交于 2019-12-11 14:26:12
问题 I'm relatively new to cypress, however, whenever I run cy.visit on localhost the XHR requests continuously run. This does not happen if I am visiting a remote URL. Here's the code: describe('Applicant Login', () => { it('focuses input on login box', () => { cy.visit('http://localhost:3000/login') }) }) Cypress continually runs XHR requests over and over until I stop. I'm running a vue.js app via nuxt.js. Here's the log output: I have no errors, no request or response info, the continuous

How to make sure page loads completely in cypress

拟墨画扇 提交于 2019-12-11 14:17:42
问题 I am working in cypress. Steps to repro I just visit the login page by cy.visit()-spinner is loading passed the credentials using type-spinner is still loading click on submit.-spinner is still loading its throwing error .. why because the login page XHR calls didnt get completed thats why still we can see spinner loading in top and i tried to click the submit button before it gets loaded,may be because of poor network-telling invalid credentials. 回答1: I believe you have to wait for the XHR

Cypress test need to receive a valid token and then redirect to another website

橙三吉。 提交于 2019-12-11 13:41:56
问题 I would need to access a MS website , enter the test email, then a pop up displays, select an account and enter password. Now at this stage, receives a valid token from the MS Website and then system will be redirected to another test_site . In this scenario, how can I redirected to that test_site using Cypress so that I can perform testing in that test site. Below is my Commands.js getLoginToken() var accessToken; Cypress.Commands.add('getLoginToken', () => { cy.request({ method: 'POST', url

How do I assert against objects with spies in Cypress?

久未见 提交于 2019-12-11 09:38:23
问题 I am using Cypress spies to test client-side analytics. My intent in this test is to confirm that identify has been called like so: identify('myemail@email.com', { groupId: 1002, groupName: "myGroup", someProp: 1, anotherProp: 2 }) I hook the spies into emitter events on a global analytics object in window:before:load (note the while loop is to deal with delays in the library loading): Cypress.on("window:before:load", async (win: Window) => { const sleep = (n = 1) => new Promise(r =>

How do I wait until a cookie is set?

两盒软妹~` 提交于 2019-12-11 08:07:59
问题 I am writing the acceptance tests for my application's login feature. At some point, I want to double-check the cookie's expiry time. Upon clicking on the "Login" button, a graphql query is sent to my server which responds with a Jwt. Upon reception of the jwt, the application sets the cookie with document.cookie = ... In my Cypress test, I check the token in the following way: Then("sa session s'ouvre pour {SessionDurationType}", expectedDuration => { cy.get('@graphql').then(() => { cy.wait

Cypress: Could not able to retrieve a specific data from downloaded excel-sheet

[亡魂溺海] 提交于 2019-12-11 07:49:44
问题 Below is the Excel from which i need 'SIP' data '37046654' enter image description here enter image description here I have tried below cypress code but it is failing as it is expecting all the data in the excel-sheet Cypress Code: describe('API Testing with Cypress', () => { it('Validate the header', () => { responsebodydata = cy.readFile('C:/Users/backNew.csv').should('eq','37046654') cy.log (responsebodydata) }) }) Assertion result: Failed with timeout by following output: expected 'SIP