63 questions
0
votes
1
answer
82
views
In cypress, I wanted to execute a flow based on a web locator visiblity. How to achieve it? [duplicate]
In my web page I have a locator which is identified by...
cy.get('.app-text')
In my case, I want to execute different flows based on the visibility of the above locator in the page.
If above locator ...
3
votes
1
answer
105
views
Cypress - How to only click button if it contains "chevron_right"
This button has 2 states, "chevron_right" when disabled. And "expand_more" when enabled.
Its default state is "chevron_right"
The following code will click on the button ...
-1
votes
1
answer
88
views
Cypress If-Else using Contains [closed]
My script looks like below
const item ["a1", "a2",..............,"a45"]
const regex = new RegExp(`${item .join('|')}`, 'g')
if(cy.get('body').contains(regex)){
...
1
vote
1
answer
68
views
How to skip failing part in Cypress test script
what is expected from the below code is get_plz_ChooseGroup will be skipped and not trigger a test failure if the element is not visible after 5000 seconds
Login_Page_POS.get_plz_ChooseGroup({ timeout:...
0
votes
0
answers
45
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
...
0
votes
1
answer
39
views
Making a function inside an if statement run until you get a false value for the conditional using JS in Cypress
I am writing a test in Cypress where I enter two values into two separate inputs and then compare them by clicking a button. If the button displays "=", I need to reset and reenter two new ...
0
votes
2
answers
589
views
cypress - how to continue running loop after assertion error
I have test that opens every item on the list. Then it validates if there are no empty ('--') fields. I want to log in console that there were empty fields and go to another item and run the loop till ...
0
votes
2
answers
70
views
If condition fails and does not go in else block as using 'contains' [closed]
In the Material UI table there is one record which can exist or not.
The scenario is if that row is present based on 'Name' column then delete it, otherwise go to the else block and log that record is ...
-1
votes
3
answers
651
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
254
views
CSS property: display: none Cypress error - Cannot click Add buttons to add products to basket
I'm currently building a e2e regression test suit for an eCommerce website developed in Angular JS, I have written a loop and provided a condition in it, this is my code:
const productText =...
0
votes
1
answer
113
views
How to handle hidden elements in Cypress with if statement? [duplicate]
I have an element job-ad which is dynamic i want it to be handle when it’s displayed and not displayed
For example if .job-ad is displayed log me a text it’s Visible, but else log it’s hidden. I tried ...
0
votes
1
answer
140
views
if-else containing a cy.get as an condition
I am trying to create an if-else condition that includes cy.get()
if (!cy.get('.modal.modal--active')) {
cy.reload()
} else {
// some codes here
}
Upon testing the code the .modal.modal--...
0
votes
1
answer
838
views
How to wait until all images have loaded before running Cypress test?
I have a Nextjs project that is using Percy (with Cypress integration) to run visual tests. My project fetches images from a CMS. How can I make sure all images on the page have loaded before (taking ...
-1
votes
1
answer
412
views
How to scroll the table in a page and catch all the elements using each in cypress? [closed]
I have 30 rows in a table and I need to perform scroll twice or it may be thrice if rows increases in future.
I am using each and store first 20 element with 1 scroll but the element I need will need ...
-1
votes
1
answer
88
views
How to be able to handle both cases of element exists and does not exist? [duplicate]
I would like to have the ability to handle the situation of both cases: the element exists and does not exist.
All my trials ended with an exception when it didn't find the item and therefore I couldn'...
0
votes
2
answers
143
views
Do stuff according to whether an element exists or not
I want to know whether an element exists or not and do stuff according to that.
I tried many options but failed.
For example:
cy.get(deleteCellButtonLocator).then(($el) => {
if ($el.length > ...
1
vote
2
answers
331
views
Cypress doesn't recommend conditional testing, what are the other ways to achieve this without writing flaky tests
We have a table in our application:
if the table length is more than 5 it shows the pagination and if the length is less than 5 it doesn't
Cypress doesn't consider it a good practice to use conditions ...
0
votes
5
answers
948
views
how to pass an assertion in if condition using cypress without halting the execution in case of assertion failure
I am trying to pass an assertion to if condition and execute a logic when the condition is met and another logic when condition is failed.
Since the test is failing on failure of assertion i am not ...
1
vote
2
answers
565
views
Unable to find the element to check if it exists in the before() hook in cypress.io [duplicate]
I have the following lines of code in my before() hook.
before(() ==> {
cy.get(this.testPopup).then(($el) => {
if ($el.length) {
cy.get(this.testPopupCloseButton).click();
cy.get(...
0
votes
1
answer
255
views
Pagination in Cypress
Use case: I have to search and click the course.
I have 10 pages, each page contains 20 courses. I need to find the course(which is random). If the course is available in the first page, it will click ...
1
vote
1
answer
548
views
cypress conditional testing with labels/text
How do you do conditional testing in cypress with labels?
For example: I want to know if there is the "ole" written in between the span:
<div>
<span role="test">ole&...
0
votes
2
answers
149
views
Not able to bypass a condition in cypress when it's not visible
In Cypress I'm simply trying to to close a filter using it's class "const filterRemoveElement = '.position-absolute > img';" But the problem is that if cypress found that element then it'...
1
vote
1
answer
954
views
How to skip a Cypress test based on an IF ELSE statement?
I want to skip a test case based on the IF ELSE statement. I'm sharing the code below but although it couldn't find the element rather than skipping, it's failing the test case then continues with the ...
0
votes
2
answers
128
views
How to rewrite if condition in groovy to Cypress?
I have some front-end test written in Groovy and I need to rewrite them in Cypress.
I am currently having problem with rewriting an if condition to Cypress.If the popin window is displayed click on it,...
0
votes
4
answers
4k
views
How to avoid cy.wait() in cypress test
I am trying to avoid the wait() function on my tests.
I'm aware, based on the official docs, that Cypress works async and we dont need to use the wait() function, especially the visit() command ...
1
vote
3
answers
223
views
Cypress: Value of Variable is not saved when go out IF statement [duplicate]
I have a table as image below.
I try to check in checkboxes having 'ST - ' text then Delete them.
Here my code:
cy.get('td').invoke('text').then(text => {
//1st IF
if (text ...
1
vote
1
answer
196
views
Cypress assertion of two classes
I have this code on Cypress
cy.wrap(null).then(() => {
const $calculatorPayout = Cypress.$(".flex.flex-col.items-center.justify-center.h-\\[50px\\].w-10.border.border-solid.border-black-...
0
votes
1
answer
208
views
Cypress cy.its('length') does not work when single element appeared but works correctly for multiple elements
In Cypress, I am trying to write function to type in the editable field. If multiple elements found for the same locator, then enter the string in last editable field, else type the text in the ...
0
votes
3
answers
459
views
Cypress, If else doesn't work it only going into if condition
I am trying to add else if /switch case in my test , but else if - it goes to only if case, if 'if' fail it doesn't go in else if it's happen in switch case also
it('Deve cadastrar um CNPJ válido', () ...
1
vote
3
answers
235
views
Cypress: check if an element is present based on one of its attributes
I'm writing Cypress End-to-End tests where I need first to check if a specific button is present on my web page (conditional testing).
This is what I did:
cy.get('body')
.then($body => {
...
0
votes
1
answer
157
views
How to do Conditionals in Cypress
In my e2e, I need to check if the datatable is populated first before before checkboxes in the table are clicked.
I am able to check the count like so
cy.get('.p-datatable-table').find('tr').its('...
2
votes
1
answer
266
views
Act when element exists, but don't fail when it doesn't (Cypress E2E tests)
I'm writing E2E tests in Cypress (version 12.3.0). I have a page with a table in a multi-step creation process that requires some data from back-end application. In some cases (rarely, but it occurs) ...
0
votes
2
answers
283
views
Is there a way to return true or false if an element is clickable. I want to check if one of 3 imprint links is clickable
I want to find out if imprint links are working. Sometimes there are cookie consistent banners and you can not click the link on the page.
But is there a way to find out if there is a second imprint ...
1
vote
2
answers
124
views
After updating to cypress 12.0.0, my test is throwing an error in the cypress-if package
After updating to cypress 12.0.0, I get the following error, how can I fix it?
1
vote
1
answer
998
views
Cypress test if an element does't exist conditional
I'm working on a cypress test that toggles a checkbox that toggles items which causes the button to appear and it click the button. The test itself works as intended for when there are items togglable....
7
votes
2
answers
7k
views
Cypress returning Synchronous value within Async command?
So I think this is probably me mixing up sync/async code (Mainly because Cypress has told me so) but I have a function within a page object within Cypress that is searching for customer data. I need ...
2
votes
4
answers
517
views
How to check that at least one input in a group has a value
I have some inputs in the following div
cy.get("div[data-test-letterinputcontainer='0']")
One of them have a value, but it is not known which. It could for example look like this
<div ...
0
votes
2
answers
282
views
Conditional Testing with Cypress e2e
I have a test case of my site with cypress. however the site, which is been built in vue.js has lets say 2 journeys. in one of them there is an button which I want to click. So, what I want to do is ...
1
vote
1
answer
990
views
How do you make a conditional test if an element exists in Cypress?
There is a lot online about testing if an element exists, but i can't find anything really specific that could help in my case.
For context, I am working on a website that has certain elements in them ...
4
votes
2
answers
2k
views
Cypress - Conditional test with timeout
I'm trying to do something very similar to this post:
https://stackoverflow.com/questions/56145926/how-to-check-if-element-exists-using-cypress-io
I'm using typsecript. Here's my code:
cy.get("...
1
vote
3
answers
2k
views
Cypress - How to use if statement with contains
so I have to use cy.contains to find the element I want, but all I can find online is how to use if() with cy.find or cy.get if there a way to do this with contains?
Example code:
if(cy.contains('div....
4
votes
1
answer
711
views
Dialog that may or may not appear on page start
I need to handle the case where my page may display a popup dialog at the load stage, or it may not appear. Clicking anywhere will remove it and I'm not interested in testing this dialog, but it ...
2
votes
2
answers
3k
views
How to Skip a Test if an element is not present in Cypress
I am writing a test in which if I land on a page and if any records are available, I need to click on three dots buttons near the record. But I should skip the test if no records are available on the ...
0
votes
2
answers
562
views
Is it possible to keep executing test if element wasn't found with Cypress [closed]
I have a case when I need to wait for element (advertising), if it's visible then needs to click it, but if element wasn't found after timeout then needs to keep executing a test.
How to handle the ...
0
votes
2
answers
3k
views
How to work on random pop ups in cypress? [duplicate]
I have an application, where feedback pop up comes in a page randomly; like pop up may or may not come in the page after loading it for nearly 3000ms. How to handle this pop up in cypress.
I tried ...
1
vote
2
answers
612
views
How to have two different tests for conditional tables that render on a page based upon the prop passed by parent?
I have a cypress test that checks the table on a page, however there are two different tables that could render depending on the table type conditional.
If the type of the table is product one table ...
0
votes
3
answers
1k
views
Conditional Tests in Cypress using data-cy attributes as selectors
I see some posts about this exact topic, but none of them using data classes like I am as selectors, so it makes this conditional test a bit harder to write.
The idea is that I have a table with ...
0
votes
3
answers
555
views
cyoress test validate div tag ID contains value
On the HTML page nested div tags are there. And either div tag ID = x or tag ID =y. in different HTML pages.
<--! example 1 -->
<body>
<div>
<div></div>
&...
1
vote
1
answer
633
views
how can i implement if else conditional statements in cypress? is it reliable?
I have an E-commerce application, in which i want to delete the products from my cart if anything is there before my automation tests starts(kind of cleaning up the cart before test starts). We are ...
1
vote
2
answers
460
views
How to proper Conditional Testing
I just want to ask how to properly conditional testing? I have this code here
cy.get('[data-slug="add-to-any"] > .plugin-title > strong').then(($slug) => {
if (expect($...