cypress

cypress - 403 forbidden error when visiting main site

不问归期 提交于 2019-12-11 06:21:26
问题 I am trying to cy.visit() my single page application that requires my certificate loaded in the browser to run correctly. When running a test, it fails with a 403 forbidden error. There is a terrible work-around where I open a new tab in the cypress/chrome browser window and go directly to my web app, which prompts for me to select my certificate a few times and then loads the page. If I then reload the test, it somehow keeps my certificate selections and goes straight to the page and runs

Cypress test runner is not instantly running when the 'example-spec.js' is modified/changed

怎甘沉沦 提交于 2019-12-11 04:54:33
问题 Cypress test runner is not instantly running when the 'example-spec.js' is modified/changed. The versions of test runners are Chrome 68 and Electron 59 in cypress. cypress installed version is 3.1.0. Also using the atom.js editor. The desktop machine is Windows 8.1 Pro From the command prompt, first I run this command to go to this directory' cd C:\node_modules.bin ' Then run ' cypress open '. This will open the cypress app. Folder directory below and screenshot added C:\node_modules.bin

Cypress.io + TypeScript. Assertion call in beginning of test

非 Y 不嫁゛ 提交于 2019-12-11 01:00:00
问题 I am new to Cypress.io and TypeScript. So I do not understood some stuff here. My code: //Test describe('TEST description', function () { it('newJobCreation', function () { //Some code 1 var numberBefore = cy.get('#idOfItem') var _numberBefore = +numberBefore //Some code 2 var numberAfter = cy.get('#idOfItem') var _numberAfter = +numberAfter //Assertion expect(_numberBefore-1).equals(_numberAfter) //Same result if I use: assert.equal(_numberBefore-1, _numberAfter) }) }) Lets say _numberBefore

Cypress request wait by default?

白昼怎懂夜的黑 提交于 2019-12-10 20:55:00
问题 I need Cypress to wait for any xhr requests to complete by default before performing any operations. Is there any way to make this as a default or any other alternatives because the application I am testing is slow and makes a lot of api calls? Edit: By writing a single statement for every api request is getting messy and unnecessary work. Need a way to make this easier. 回答1: Found something that works for me here https://github.com/PinkyJie/cypress-auto-stub-example Look for cy

Avoid using cy.wait() to wait for a page to load due to aborted get request cypress

旧巷老猫 提交于 2019-12-10 17:21:48
问题 I'm running a cypress test that requires a page to load before clicking an element and logging in, but for some reason a failed (and aborted) GET request is causing the page to take forever to load and eventually it times out unless I add a cy.wait(6000) before the cy.click() call. I need to somehow wait for the page to load without using a cy.wait(). How can I do this, given that I cant fix the aborted GET request? cy.visit(loginUrl) cy.url().should('contain', '#/loginPortal') cy.wait(6000)

How can I use Cypress.io to assert that a file download has been initiated without actually downloading?

僤鯓⒐⒋嵵緔 提交于 2019-12-10 15:35:21
问题 The download is initiated by setting location.href = [some url to an image] I want assert, as close as possible, that the download will succeed but without actually performing the download. That the URL is correct can be assumed. 回答1: What you essentially want to do is stub a call to location.href using cy.stub(), but testing that your application has called location.href and asserting the url passed to it is a bit tricky since href is an attribute, not a function. Stubs cannot replace

Drag and drop is not happening in Cypress.io test

怎甘沉沦 提交于 2019-12-10 15:24:08
问题 I am trying to drag an element and then drop it into a drop zone area, but the test is not performing the drag and drop action in Cypress.io. It would be really helpful if someone could advise about the potential issue here. There are no errors throwing, but still, the drag and drop is not happening here. describe('Verify the drag and drop test', function() { it.only('Check whether the drag and drop of an item is working fine', function() { cy.visit('http://www.seleniumeasy.com/test/drag-and

Cypress expect element to contain one string or another string

做~自己de王妃 提交于 2019-12-10 11:30:13
问题 I'm trying to do some Cypress assertions to see whether or not it contains one or another string. It can be in English or Spanish, so either one should pass the test. cy.get(el).should('contain', 'submit').or('contain', 'enviar') obviously doesnt work. const runout = ['submit', 'enviar'] const el = '[data-test=btn-submit]' function checkArray(arr, el) { for(let i = 0; i < arr.length; i++) { if(cy.get(el).contains(arr[i])) { return true } else { if (i === arr.length) { return false } } } } cy

How to check for an element that may not exist using Cypress

不想你离开。 提交于 2019-12-10 02:03:39
问题 I am writing a Cypress test to log into a website. There are username and password fields and a Submit button. Mostly logins are straightforward, but sometimes a warning dialog appears first that has to be dismissed. I tried this: cy.get('#login-username').type('username'); cy.get('#login-password').type(`password{enter}`); // Check for a possible warning dialog and dismiss it if (cy.get('.warning')) { cy.get('#warn-dialog-submit').click(); } which works fine, except that the test fails if

Cypress pipe console.log and command log to output

江枫思渺然 提交于 2019-12-09 00:32:22
问题 Is it possible to redirect or capture Cypress browser log and command log to output? I read some Cypress github issues on this topic. But I don't know how to make it work. Basically, I want to capture all the Cypress GUI command logs in the headless non-GUI mode. If I can include browser console log will be even better. The purpose is to understand what happened when a test fails. I use teamcity as ci. Here is an example of my build log. I want to see all the command log here too. Actually,