flat-rocket-60743
07/12/2022, 11:14 PMflat-rocket-60743
07/12/2022, 11:14 PMadorable-smartphone-87280
07/13/2022, 12:51 AMflat-rocket-60743
07/13/2022, 1:12 AMquick-forest-42096
07/13/2022, 7:38 AMcy.get('table.c-table').get('td.campaigns-table-campaign-name').contains(mockData.campaignName).siblings('.campaigns-table-campaign-action-buttons').get('button[data-test="delete-campaign-button"]').click()
I expect to find a td
with the class campaigns-table-campaign-name
that contains mockData.campaignName
as its content, there is only one of those, and it has 5 siblings, of those I want to find the one with class campaigns-table-campaign-action-buttons
and click a button on it.
But when I run I get cy.click() can only be called on a single element. Your subject contained 50 elements. Pass { multiple: true } if you want to serially click each element.
which effectively refers to all 50 elements in my table.
Is something wrong with my syntax?astonishing-electrician-44897
07/13/2022, 8:26 AMcy.get('table.c-table')
.get('td.campaigns-table-campaign-name')
.contains(mockData.campaignName)
.siblings('.campaigns-table-campaign-action-buttons').within(() => {
cy.get('button[data-test="delete-campaign-button"]')
.click();
});
quick-forest-42096
07/13/2022, 8:31 AMquick-forest-42096
07/13/2022, 8:31 AMblue-quill-43979
07/13/2022, 9:45 AMjavascript
cy.request('GET', myUrl).its('body').then((rep) => {
let targetFile = rep.find(f => f.titre === fichierRessource);
return targetFile;
}).as('targetFile'); // this.targetFile is an array instead of an object
rhythmic-guitar-55789
07/13/2022, 10:49 AMcy.request
is not quite the right tool for the job here, try using fetch
for this, checkout this example here: https://github.com/cypress-io/cypress-example-recipes/blob/master/examples/server-communication__request/cypress/e2e/spec.cy.js#L52acceptable-tailor-66244
07/13/2022, 11:01 AMcareful-computer-31749
07/13/2022, 11:23 AMgray-kilobyte-89541
07/13/2022, 11:51 AMtargetFile
should be an object and not an array?blue-quill-43979
07/13/2022, 12:15 PMrep.find(f => f.titre === fichierRessource);
is an object and not an array indeedgray-kilobyte-89541
07/13/2022, 1:25 PMblue-quill-43979
07/13/2022, 1:32 PMcuddly-thailand-33926
07/13/2022, 1:32 PMbitter-fountain-36713
07/13/2022, 4:04 PMjs
cy.get('table.c-table')
.contains('td.campaigns-table-campaign-name',mockData.campaignName)
.siblings('.campaigns-table-campaign-action-buttons')
.find('button[data-test="delete-campaign-button"]')
.click()
gray-kilobyte-89541
07/13/2022, 4:43 PMcareful-computer-31749
07/13/2022, 6:38 PMfreezing-piano-2792
07/14/2022, 8:48 AMfreezing-piano-2792
07/14/2022, 8:49 AMcuddly-thailand-33926
07/14/2022, 9:04 AMmany-city-96644
07/14/2022, 10:05 AMgray-kilobyte-89541
07/14/2022, 11:54 AMfreezing-piano-2792
07/14/2022, 12:45 PMfreezing-piano-2792
07/14/2022, 12:45 PMfreezing-piano-2792
07/14/2022, 12:45 PMmany-city-96644
07/14/2022, 12:51 PMfreezing-piano-2792
07/14/2022, 2:42 PMcypress open --e2e --browser electron
?