lemon-toothbrush-55306
02/14/2023, 7:46 PMjs
Cypress.Commands.add('getBySel', (selector, ...args) => {
return cy.get(`[data-test-id="${selector}"]`, ...args);
});
js
cy.getBySel('SUPPLY KEY').then((key) => {
console.log('Key - cy.getBySel',key);
let SUPPLY_KEY = key;
cy.wrap(SUPPLY_KEY).as('wags');
});
But the val I'm getting is (Attach to second Image).
Any help pls?gray-kilobyte-89541
02/14/2023, 9:25 PMlemon-toothbrush-55306
02/14/2023, 9:58 PMlemon-toothbrush-55306
02/14/2023, 9:58 PMlemon-toothbrush-55306
02/14/2023, 9:59 PMlemon-toothbrush-55306
02/14/2023, 10:02 PMlemon-toothbrush-55306
02/14/2023, 10:03 PMmodern-dawn-86006
02/14/2023, 10:05 PMmodern-dawn-86006
02/14/2023, 10:07 PMlemon-toothbrush-55306
02/14/2023, 10:22 PMlemon-toothbrush-55306
02/14/2023, 10:22 PMpowerful-orange-86819
02/15/2023, 9:33 AMlemon-toothbrush-55306
02/15/2023, 11:28 AMlemon-toothbrush-55306
02/15/2023, 11:28 AMlemon-toothbrush-55306
02/15/2023, 11:28 AMlemon-toothbrush-55306
02/15/2023, 11:29 AMlemon-toothbrush-55306
02/15/2023, 11:29 AMlemon-toothbrush-55306
02/15/2023, 11:30 AMlemon-toothbrush-55306
02/15/2023, 11:30 AMpowerful-orange-86819
02/15/2023, 11:30 AMpowerful-orange-86819
02/15/2023, 11:30 AMpowerful-orange-86819
02/15/2023, 11:31 AMimportant-country-59976
02/15/2023, 11:36 AMcy.get(anElement).invoke('text').then((aText) => {
cy.readFile('yourFixtureFile.json').then((anObject) => {
anObject.aKey = aText
cy.writeFile('yourFixtureFile.json', anObject)
})
})
* To use the stored text in another test
cy.readFile('yourFixtureFile.json').its('aKey').then((aText) => {
cy.get(anElement).invoke('text').then((anElementText) => { expect(aText).have.contain(anElementText) })
})
I hope this will help youlemon-toothbrush-55306
02/15/2023, 4:18 PMlemon-toothbrush-55306
02/15/2023, 4:19 PMjs
cy.fixture('kabiUser.json').then((kabiUser) => { })lemon-toothbrush-55306
02/15/2023, 4:19 PM