elegant-microphone-18288
03/14/2023, 8:42 PMsquare-quill-93570
03/14/2023, 10:18 PMdata-cy
attribute, but when I run a test that clicks on this button, Cypress is unable to find it. Using a normal user action does click on the button and fire its event successfully, but Cypress is unable to. What's more is that using Cypress's element selector also does not reveal any information about the button, simply glossing over it as if it didn't exist. Is there a reason why Cypress is unable to find the button?millions-flower-39293
03/15/2023, 4:21 AMpipeline {
agent {
docker {
label 'default'
image 'cypress/base:14.16.0'
}
}
stages {
stage('Install Dependencies') {
steps {
echo "Running build ${env.BUILD_ID} on ${env.JENKINS_URL}"
sh 'npm ci'
sh 'npm run cy:verify'
}
}
stage('CBS UI Test') {
environment {
CYPRESS_RECORD_KEY = credentials('cypress-record-key')
CYPRESS_trashAssetsBeforeRuns = 'false'
}
parallel {
stage('Tester A') {
steps {
echo "Running build ${env.BUILD_ID} on Tester A"
sh "NO_COLOR=1 xvfb-run -a npx cypress-cloud run --parallel --record --key ${env.CYPRESS_RECORD_KEY}"
}
}
stage('Tester B') {
steps {
echo "Running build ${env.BUILD_ID} on Tester B"
sh "NO_COLOR=1 xvfb-run -a npx cypress-cloud run --parallel --record --key ${env.CYPRESS_RECORD_KEY}"
}
}
stage('Tester C') {
steps {
echo "Running build ${env.BUILD_ID} on Tester C"
sh "NO_COLOR=1 xvfb-run -a npx cypress-cloud run --parallel --record --key ${env.CYPRESS_RECORD_KEY}"
}}}}}}
gray-father-52711
03/15/2023, 8:10 AMpending
status) the app is displaying some network error notification. I want to test that:
- before 30s a spinner is visible
- after 30s a network error notification is visible
I've added an intercept for this call and delayed the response for more than 30s and it works, test is passing, but the test takes too much time.
So my question is: can I use cy.clock
and cy.tick
somehow to control the time on the frontend and make the test to run much faster? 🙏victorious-traffic-84253
03/15/2023, 12:36 PMCypress.Commands.add(
"shouldNotBeActionable",
{ prevSubject: "element" },
(subject) => {
cy.on("fail", (error) => {
// We expect the click to fail with one of these messages
const disabledMessage = "`cy.click()` failed because this element is";
if (error.message.includes(disabledMessage)) {
expect(error.message).to.include(disabledMessage);
return false;
}
// Using Mocha's async done callback to finish this test so we prove that an uncaught exception was thrown
throw error;
});
// Assumes this click fails
cy.wrap(subject)
.click({ timeout: 100 })
.then(() => {
throw new Error(
"Expected element NOT to be clickable, but click() succeeded"
);
});
}
);
This is used in my tests like so
it.only("opens step settings drawer but doesn't allow changes", () => {
cy.visit("/myRoute");
Assertions above are all ran…
cy.get("button").shouldNotBeActionable();
…but assertions below aren't being ran
flat-night-46072
03/15/2023, 1:55 PMcurved-mechanic-66366
03/15/2023, 2:27 PMcy.get('[data-icon="cloud-upload-alt"]').attachFile('images/Group 7 (1).png');
prehistoric-restaurant-72560
03/15/2023, 2:51 PMmillions-megabyte-24728
03/15/2023, 3:15 PMcold-bird-96191
03/15/2023, 8:15 PMnice-terabyte-28126
03/16/2023, 2:05 AMcy.get('input').should('have.value', '***')
it still returns the raw string, and as so far I've been unable to find a way to verify if the text in the input field is currently hidden or notincalculable-rainbow-43330
03/16/2023, 5:50 AMmagnificent-lamp-44201
03/16/2023, 6:08 AMexample.cy.js
javascript
describe('Sign up', () => {
const password = "test-password";
let inboxId;
let emailAddress;
let link;
it('sample', () => {
cy.visit('http://localhost:3000/');
cy.get('h2').contains('Iniciar');
cy.wait(5000);
cy.get('a').contains('Don\'t').click(); cy.get('label[for="password"]').contains('Create a Password');
cy.createInbox().then(inbox => {
// verify a new inbox was created
assert.isDefined(inbox)
// save the inboxId for later checking the emails
inboxId = inbox.id
emailAddress = inbox.emailAddress;
// sign up with inbox email address and the password
cy.get('input[name="email"]').type(emailAddress);
cy.get('input[name="password"]').type(password);
cy.get('button[type="submit"]').contains('Sign up').click();
cy.waitForLatestEmail(inboxId).then(email => {
// verify we received an email
assert.isDefined(email);
console.log("print the body")
console.log(email.body)
// extract the link
link = /<a\s+(?:[^>]*?\s+)?href=(["'])(.*?)\1/.exec(email.body)[2];
console.log(link)
});
});
});
it('should works', () => {
console.log('Print the URL: ' + link)
cy.visit(link);
});
it('should works', () => {
// it displays the link sent through email, but when I visit it throws an error
// see image attached
console.log('Print the URL: ' + link)
cy.visit(link);
});
tall-dress-31592
03/16/2023, 6:08 AMacceptable-angle-31500
03/16/2023, 12:16 PMplain-candle-1839
03/16/2023, 12:54 PMnumerous-receptionist-75365
03/16/2023, 2:03 PMcy.task('coverageReport')
fails with the following error:
The argument 'path' must be a string or Uint8Array without null bytes. Received '/Users/redacted/Documents/projects/redacted/backoffice-fe/cypress-coverage/lcov-report/backoffice-fe/\x00commonjsHelpers.js.html'
I don't know what that file is and why the name starts with a null byte. This happens both on my machine and in CI.
I cannot find anything on Google, I would be very thankful if anyone had a clue.
Thankswitty-wolf-77896
03/16/2023, 3:22 PMdescribe('CKEditor 5', () => {
it('types text into a CKEditor 5 editor instance and tests to make sure the text equals whatever is typed in', () => {
cy.visit('https://ckeditor.com/ckeditor-5/demo/feature-rich/')
cy.get('div[data-demo-type="feature-rich"] div[contenteditable]').type('{ctrl+a}{del}')
cy.get('div[data-demo-type="feature-rich"] div[contenteditable]').type('Hello CKEditor')
cy.get('div[data-demo-type="feature-rich"] div[contenteditable]').invoke('text').should('eq', 'Hello CKEditor')
})
})
freezing-midnight-9121
03/16/2023, 4:06 PMsquare-zoo-92250
03/16/2023, 6:05 PMstrong-twilight-85943
03/16/2023, 7:37 PMfresh-van-160
03/17/2023, 4:32 AMclever-night-39043
03/17/2023, 5:29 AMcy.request()
with the following syntax:
cy.request(
{
method: method,
url: format(endpoint, option),
failOnStatusCode: false,
headers: headers,
body: normalisedRequest
})
It works when the body
is an object or string, but when the body is a number, the test fails and selector playground crashes.
The error is
The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received type number (1)
TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received type number (1)
at new NodeError (node:internal/errors:372:5)
at write_ (node:_http_outgoing:742:11)
at ClientRequest.write (node:_http_outgoing:707:15)
at ee.write (<embedded>:1955:83025)
Please help. I need to use only a number as request body. Thanksbrave-doctor-62978
03/17/2023, 12:57 PM<--- JS stacktrace --->
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
1: 0x100c5df7c node::Abort() [/opt/homebrew/Cellar/node/19.8.1/bin/node]
2: 0x100c5f448 node::ModifyCodeGenerationFromStrings(v8::Local<v8::Cont
busy-ambulance-42459
03/17/2023, 2:34 PMadamant-toddler-18579
03/17/2023, 2:54 PMripe-continent-46695
03/17/2023, 4:01 PMit('Missing Script Issue', () => {
cy.visit('https://www.oldelpaso.com/products/shells-tortillas');
cy.get('.result-template').should('exist').and('not.be.empty');
});
If you inspect the source of this page outside of Cypress, you will see that it always contains this underscore template content within the script tags.
https://www.oldelpaso.com/products/shells-tortillas
Cypress 12.7.0 (upgraded from Cypress 10.11.0 to try and fix this issue)
This happens on all browsers
To make things more confusing, this same exact underscore template does exist in the DOM for other pages when run with Cypress: https://www.oldelpaso.com/products/taco-shells-stand-n-stuff-15-count
I'm not sure if there is something we can do to fix this issue, or if this is possibly a bug in Cypress.
Thanks for any and all help!blue-belgium-36090
03/17/2023, 4:54 PMbusy-agency-3812
03/18/2023, 12:02 AMconst getDivisionBody = () => {
return {
data: {
division: {
utilitiesConfig: {
electric: false,
},
__typename: 'Division',
},
},
};
};
My fixture had electric set to false but I want to be able to create a function which can toggle the value to false or true. First, I wanted to make sure the intercept could take this variable before I modify it.
so I did this:
cy.intercept('POST', '/graphql', (req) => {
if (req.body.operationName === 'getDivision') {
req.reply(`${getDivisionBody}`);
}
});
Now my cypress is able to see the variable but it returns this, including the function part
function () {
return {
data: {
division: {
utilitiesConfig: {
electric: false,
},
__typename: 'Division',
},
},
};
}
And if I do
cy.intercept('POST', '/graphql', (req) => {
if (req.body.operationName === 'getDivision') {
req.reply(getDivisionBody);
}
});`
gorgeous-forest-77630
03/18/2023, 10:45 PM/// <reference types="cypress" />
import {homePageGeant} from '../../../support/Pages/SuperMarkets'
const datatest = '../fixtures/datatest.json'
describe('Get the page information',()=>{
it('Store the page information', ()=>{
homePageGeant.visitHomepage();
homePageGeant.typeSearchInput('Cafe');
homePageGeant.clickSeeAllProducts();
homePageGeant.storeEachPMarca();
homePageGeant.storeEachH2();
homePageGeant.storeEachPPrice();
homePageGeant.pushIntoCoffeeListArray();
homePageGeant.writefile();
})
it('check json', ()=>{
cy.readFile(datatest).then((str)=>{
cy.wrap(str).pause()
cy.wrap(str[0]).pause()
cy.wrap(str[0][1]).pause()
cy.wrap(str[1]).pause()
cy.wrap(str[0].ProductBrand).pause()
})
})
})
Result from the pipeline:
1) check json
1 passing (31s)
1 failing
1) Get the page information
check json:
AssertionError: Timed out retrying after 4000ms: `cy.readFile("../fixtures/datatest.json")` failed because the file does not exist at the following path:
`/home/runner/work/Scapping/fixtures/datatest.json`
Any ideas?