mysterious-belgium-25713
09/29/2022, 2:04 PMjs
cy.visit("www.toto.com")
cy.get("username").type("username")
cy.get("password").type("password")
cy.get("submitbutton").click()
cy.origin('www.titi.com', () => {
// Now you can do stuff inside the login origin
cy.get('h1').contains('ACME CORP')
})
mysterious-belgium-25713
09/29/2022, 2:04 PMsalmon-kite-6386
09/29/2022, 2:05 PMmysterious-belgium-25713
09/29/2022, 2:05 PMsalmon-kite-6386
09/29/2022, 2:06 PMmysterious-belgium-25713
09/29/2022, 2:10 PMsalmon-kite-6386
09/29/2022, 2:13 PMmysterious-belgium-25713
09/29/2022, 2:15 PMsalmon-kite-6386
09/29/2022, 2:17 PMchilly-queen-22182
09/29/2022, 7:35 PMstale-optician-85950
09/29/2022, 9:15 PMplain-garden-5374
09/29/2022, 9:37 PMchilly-queen-22182
09/29/2022, 9:53 PMmysterious-belgium-25713
09/29/2022, 10:01 PMchilly-queen-22182
09/29/2022, 10:40 PMrough-night-37887
09/30/2022, 3:44 AMstale-optician-85950
09/30/2022, 7:45 AMgreat-answer-57072
09/30/2022, 7:49 AMdataLayer
object using Cypress. For now, I can use cy.window.its('dataLayer')
to get the data, but in my test cases, there are a lot of button clicks with routing to other pages. The dataLayer object will be refreshed.
Therefore, my question: is there any way to get the data after button clicks but before routing to the designated page?gray-kilobyte-89541
09/30/2022, 10:28 AMacceptable-tailor-43291
09/30/2022, 12:04 PMgray-kilobyte-89541
09/30/2022, 12:11 PMsalmon-kite-6386
09/30/2022, 12:11 PMgentle-accountant-4760
09/30/2022, 12:24 PM.then
response of something like this:
ts
import MessageSignerHelper from '../plugins/sales/MessageSignerHelper';
/**
* Sub page containing specific selectors and methods for a specific page
*
* @class
*/
class BarryApi{
static itemLists(requestUrl: string): any {
let itemList;
const signatureHeaders = [
{ name: 'override', value: 'hello_world' },
];
cy.task('Signature', { pathToSign, headers: signatureHeaders }).then((signature) => {
cy.request({
url: requestUrl,
method: 'GET',
headers: {
'signature': signature,
},
failOnStatusCode: false,
log: true,
})
.then((response) => {
itemList = JSON.stringify(response.body);
});
});
return itemList ;
}
}
export default BarryApi;
When I call BarryApi.itemLists('https://barrythrill.com') it returns undefined but if I add a console.log inside the .then((response)
then I can see the values so my question is how can I get the return value by doing something like
ts
let testing;
testing = BarryApi.itemLists('https://barrythrill.com');
console.log(testing);
?acceptable-hamburger-48790
09/30/2022, 12:27 PMacceptable-hamburger-48790
09/30/2022, 12:28 PMgentle-accountant-4760
09/30/2022, 12:29 PMacceptable-tailor-43291
09/30/2022, 12:31 PMwait-on
will also work? cypress.exec("wait-on https://myapp.com/")
js
cy.visit('/');
//Simulated the login
// After login
// My app takes 40-50 sec time to load
cypress.exec("wait-on https://myapp.com/");
//Will that be correct?
gentle-accountant-4760
09/30/2022, 12:31 PMacceptable-hamburger-48790
09/30/2022, 12:33 PMgentle-accountant-4760
09/30/2022, 12:34 PM