All Questions
Tagged with cypress cypress-custom-commands
99 questions
0
votes
0
answers
39
views
Cypress e2e.js file giving error while connecting SQL server using Cucumber [duplicate]
I am not able connect DB connection using Cypress. Facing issue e2e.js by giving loadDBCommand.
DBConnection.feature
Scenanrio: Connect DB using SQL Server
Given Update the Agent Details
Package.json
...
2
votes
3
answers
83
views
Expected output changes when converting function to custom command
I have this function that fetches all CSS properties and values of an element:
function getAllCssPropertiesAndValues(element: Element) {
const style = window.getComputedStyle(element)
const ...
-2
votes
1
answer
81
views
Can all commands be overwritten at once?
Suppose I want to add a log at the beginning of each command and at the end of each command. I want to be able to do that for all commands at once. So I tried:
// Define a function to intercept custom ...
0
votes
3
answers
192
views
I am facing a problem to verify element visibility if element in visible or not using cypress
When I try
cy.get('div.userId')
I want to add condition div.userId is exists/not in dom.
I am expecting not to fail test before checking existence of element in dom.
Like sometimes div.userId is not ...
0
votes
1
answer
219
views
In Cypress when running multiple spec files together the imports on each spec file are imported multiple times. Overwrites then call themselves
I have a multiple specs files in Cypress and each one imports a file named "helper.cy". helper.cy contains a Cypress.Commands.overwriteQuery overwriting the "contains" query.
When ...
1
vote
1
answer
123
views
Cypress: How to log each element click to a file?
I created a log file in which I log there various operations during my tests.
I would also like to log any elements click I perform.
However, I don't want to add a specific log instruction before each ...
1
vote
1
answer
214
views
Is it possible to assert a failure in a Cypress Custom command?
How do I assert a failure from a Cypress Custom Command? Let's say I have a custom command with a complex set of tests that can fail due to some elements not being found, can I assert the failure of ...
0
votes
2
answers
298
views
Select date from rangepicker
I am trying to add two dates in a rangepicker.
This is the command to select the date:
Cypress.Commands.add('setDatePickerDate', (selector, date) => {
const monthsShort = [
'janv.',
'févr....
0
votes
0
answers
182
views
Cypress: Trouble trying to replicate cy.origin AAD login solution on a non-local website when login is triggered automatically
I'Ve been having the following problem while trying to replicate the Azure Active Directory Authentication for a non-local website that calls the Microsoft loging page directly. I've been told to use ...
1
vote
0
answers
88
views
How to externalize cypress custom comands in npm packages
I am trying to externalize functionalities from Cypress tests written in TypeScript/cucumber, aiming for reuse across multiple repositories. In my commands.ts file, various functionalities are ...
0
votes
0
answers
23
views
When using cypress automation the Website gets log out before last it block
I am using Cypress to automate this website https://admin.britex.pw/
The issue occurs when during automation after a few It blocks, on click of a link (anchor) tag, the website gets logged out. I ...
0
votes
1
answer
75
views
Why does cy.on stop working when moved to a custom command?
I am using the following function to detect window opening and assert that it's opened to the correct URL:
const stubWindowOpen = () => {
const stub = cy.stub().as(`window-open`)
cy.on(`window:...
0
votes
1
answer
562
views
Error: Can't walk dependency graph: Cannot find module 'cypress-await' from
Error: Can't walk dependency graph: Cannot find module 'cypress-await' from '/private/var/folders/x6/q6c584hd10v7jwd_9rywn5m40000gn/T/09de0a49-817e-404a-97a9-01388d7c86c6/e2e.js.js
I am adding async ...
0
votes
1
answer
185
views
Cypress Error when using POM and Commands with Cucumber framework
I'm facing an issue with my Cypress Cucumber tests using Page Object Model (POM), custom commands, and a data.json file. The test seems to skip the first When statement. Here's how my code is ...
0
votes
1
answer
173
views
How to increase default timeout for SQL request sent from Cypress test?
I use cypress-sql-server plugin for sending SQL requests from Cypress tests. It works fine if the Data processed by the request is not large. But for big amounts of data the request fails by timeout ...
0
votes
2
answers
228
views
Is it possible to load command files in spec.js files instead of support/index.js in cypress?
Right now whenever we write a new file that contains Cypress custom commands we add it using
Cypress.Commands.add()
and then import the file in support/index.js.
But my problem here is that I've 100 ...
0
votes
2
answers
1k
views
Defining a global variable in Cypress that can be used in all test files without creating a new one everytime
I am very desperately looking for a solution to define a global variable and access it everything in all my test files. This is my commands.js. Here i am generating a random mobile number using faker....
0
votes
1
answer
29
views
From the list of values, how to select each dropdown value after some action is done using cypress?
cy.get('#gradeLevels').each(($option) => {
const optionText = $option.text();
cy.get('#gradeLevels').select('Grade 3');
cy.log('List of Grade Levels'+ optionText) })
I'm trying the ...
0
votes
2
answers
289
views
Return value from cypress custom command and reuse in another function in test.cy.js file
I have created a custom command cy.createUser("userCreate") in commands.js that creates a userID variable.
Cypress.Commands.add("createUser", (payload) => {
cy....
-2
votes
1
answer
165
views
creating tasks in cypress.config.js is not working [closed]
I have a task like this in cypress.config.js
async function setupNodeEvents(on, config) {
allureWriter(on, config);
await preprocessor.addCucumberPreprocessorPlugin(on, config);
on('task', { ...
0
votes
1
answer
84
views
Cypress (12.16) how do look for a particular ID and if it isn't found then move on to an alternate?
Pretty new to cypress (12.16) here and have a question:
I have a form that gets used in multiple areas of the app, I’m trying to turn filling it out into a command to centralize it in case we need to ...
0
votes
1
answer
119
views
Custom command and 'extra data' that ends up as undefined [closed]
I'm trying to overwrite the Cypress within method such that there's an extra argument for the callback.
Ultimately, my goal is to be able to go
cy.customCommandThatSetsAValue().within((subject, extra) ...
3
votes
2
answers
1k
views
Cypress Issues Integrating Auth0 with cy.origin and cy.session
I am currently facing a persistent issue while testing my application with Cypress, particularly when attempting to handle login through Auth0. To work around cross-origin issues, I followed the ...
2
votes
1
answer
462
views
How to log the previous subject in custom commands in Cypress
I want to add logs to my custom commands in Cypress,
for example
Cypress.Commands.add('shouldBeVisible',
{
prevSubject: 'element',
},
(subject) => {
var getText = cy....
-1
votes
1
answer
673
views
Cypress does not find fixtures for my test even when defined in cypress/fixtures [closed]
My tests store fixtures in cypress/fixtures but Cypress in unable to find them. Here is the project structure. I am using version 12.14.0 of cypress
__tests__
cypress
...
1
vote
1
answer
273
views
Cypress version 12.14.0 just cannot find command files with Typescript
I am attempting to include custom commands in my Cypress tests using typescript. It just seems so difficult to get it to work. I have moved the files in various folders but it is simply a frustrating ...
0
votes
2
answers
650
views
In Cypress, how do I interact with a newly added element to the page?
I want to use MutationObserver with Cypress because it feels like an appropriate mechanism to use for detecting specific changes occurred to the DOM and then interact with element(s) that were added.
...
-1
votes
1
answer
109
views
Cypress custom commands [closed]
If you have separate repositories for library and consumer, the custom commands defined in one repository(library) is not available in consumer repository. I get cy.samplecommmand() is not a function ...
0
votes
1
answer
60
views
Need to run a function with parameter, getting TypeError [closed]
I am following POM model in cypress where I have a use case to tick checkboxes in page from json file. My files are as below:
homePageTest.cy.js
it("some test", () => {
cy.fixture(...
0
votes
2
answers
627
views
how can I make cy.each() operate with my array in Cypress?
I have fixture file named alerts-escalation-param.params.json where I store operations with their fixture path file ,then I have a function command getOperationData that get the operation data to use ...
0
votes
1
answer
1k
views
Cypress command terminal error: is not assignable to parameter of type keyof Chainable
The Cypress e2e tests run but I do get an error related to Cypress.Commands.add('loginAs'.
My commands are stored in the folders: cypress/support/commands.ts and seem to be used by my e2e tests. So ...
2
votes
1
answer
438
views
How to return value from for loop in .then function in Cypress
//command.ts
Cypress.Commands.add("getRunID"): any => {
return cy.getData().then((response: any) => {
var JsonResponse: any = response.body;
var id: any = [];
...
0
votes
2
answers
210
views
How to increment and return contents of a JSON file for field input using Cypress custom commands
I could use some help with explaining to me how custom commands in cypress work. I am currently writing a function that reads a json file and increments the contents by 1 and want to return it to the ...
0
votes
1
answer
89
views
creating a cypress command that will get button and add infinite cypress action based on user input
I want to create a cypress custom command that based on user arguments will add cypress action and chain them together
Now I have something like this:
Cypress.Commands.add(
'selectButton',
(text: ...
0
votes
1
answer
633
views
Extending Cypress.config with own properties using Typescript
I'm trying to extend Cypress config adding my own property in this way:
Cypress.Commands.overwrite('getUser', (originalFn: any) => {
const overwriteOptions = {
accountPath: `accounts/${...
1
vote
2
answers
653
views
Cypress: Passing the param into npm script when run by CL
I tryna pass the param param1 and param2 when I run the script by command Line.
Here code in test.cy.js
it('Clean data', () => {
const param1 = process.env.npm_config_param1;
const param2 =...
2
votes
2
answers
168
views
Can't run test after installing cypress-if plugin
Installing the cypress-if plugin and adding import "cypress-if" to the e2e file is causing the test to fail.
The error message returned is:
> Cannot overwite the get query. Queries can ...
0
votes
0
answers
97
views
JavaScript Cypress : Array keys/values are not printing in console output
I'm trying to get the values of nested array object like below,
cy.readFile("excelfile_path", null).then(fulldata => {
var content = fulldata
console.log(Object....
5
votes
1
answer
826
views
Getting an error using Cypress.Commands.overwriteQuery
I am getting this error while overwriting the contains() method.
Cannot read properties of undefined (reading 'hasPreviouslyLinkedCommand') in cypress
Here is the commands.js file:
Cypress.Commands....
0
votes
1
answer
2k
views
Cypress Typescript passing optional command parameters
I'm new to Cypress and Typescript and wondering if someone could point me into the right direction.
I'm creating a custom commands like this:
declare namespace Cypress {
interface Chainable {
...
1
vote
0
answers
297
views
Unable to fix the by default blank page of cypress updated version
After updating the cypress to latest version i'm geting this error
However i added the testIsloation to false in cofigration file but I'm still getting this error
can anyone please help
0
votes
2
answers
2k
views
Cypress: wrap chained commands in one
I use this long line to check the selected value on any list on my page (using Ember power-select which is not a but a complex set of ), selector being the parent so I can target the list I want, and ...
0
votes
2
answers
676
views
Overwrite cypress commands to include a wait before they are run
I am trying to overwrite Cypress commands such as click, type and should to include some waiting time before they are executed. My motivation for this is that I want to highlight the areas the test ...
0
votes
2
answers
520
views
Cypress xpath plugin does not work with cy.type()
I am unable to figure out why the cypress xpath is not working with the type(). I have two command functions: one that looks for the element using cy.get() and one that uses cy.xpath(). Unfortunately, ...
2
votes
0
answers
368
views
How fix red error line below cy. And cypress. Keyword
The red error line are coming below cy. And Cypress. Keywords. How to resolve that issue???
No error line will come below thhat keywords
1
vote
0
answers
207
views
Can we call POM from cypress custom command
I was wondering if we could call a page object model from a cypress custom commands. If this can happen then it could make cypress automated test more powerful
0
votes
1
answer
164
views
Read Property Values in Cypress_Json File
I am trying to reach out to the "testdata":"two" property values [like 'EH']. While I was taking that property, I am facing "Cannot read property" this issue, How I fix ...
3
votes
1
answer
460
views
Issue with a recursive function in Cypress. Tests slowing down over time
I am working on a diagnostic application which can ask the user quite a large number of questions (100+). I had been using a recursive function to deal with the questions and their answering but i ...
2
votes
1
answer
137
views
How can I get my cypress custom command to ingest this data (i think i structured the data wrong)?
Alright, as the title says- i'm trying to write a custom command for a cypress test suite. The situation as as follows: I have several tests that need to select an indeterminate number of fields and ...
0
votes
1
answer
107
views
find Current running cypress command in cypress config
is there any way to find the Current running cypress command when it reaches the first time to the cypress config.ts file?
actually, I need to do something based on the command used by a user
example
...