crooked-branch-31688
05/10/2023, 12:26 PMbrief-kite-35331
05/10/2023, 12:41 PMTypescript
Cypress.Commands.add('getRandomFromList', { prevSubject: true }, (subject) => {
return cy
.wrap(subject)
.should('have.length.above', 0)
.then(function ($items) {
return Cypress._.sampleSize($items.toArray(), 1);
});
});
goToRandomCategory() {
cy.get('#homepageCategories ul').getRandomFromList().click();
}
goToRandomEndLevelCategory() {
this.goToRandomCategory();
this.goToRandomSubCategory();
}
goToRandomSubCategory() {
cy.location('pathname').should('include', '--c'); // to ensure that the category page is loaded
cy.get('[itemtype*="SiteNavigationElement"]:nth-child(2) > ul').then((subcategories) => {
if (subcategories.length > 0) {
cy.wrap(subcategories).getRandomFromList().click();
this.goToRandomCategory();
}
});
}
It only clicks the homepage category and opens first level category but doesn't go further then that.
The weird thing is that it shows category list, I can see it but the trace says the elements are not visible :/
Can you please help 😄 ?
https://cdn.discordapp.com/attachments/1105836979695915038/1105836979846914068/image.png▾
red-diamond-5625
05/10/2023, 2:43 PMprehistoric-television-46163
05/11/2023, 1:52 AMblue-river-76581
05/11/2023, 12:09 PMhttps://cdn.discordapp.com/attachments/1106191353991401573/1106191354893172837/image.png▾
https://cdn.discordapp.com/attachments/1106191353991401573/1106191355266469948/1.PNG▾
https://cdn.discordapp.com/attachments/1106191353991401573/1106191355560067194/2.PNG▾
elegant-insurance-66438
05/11/2023, 2:38 PMhttps://cdn.discordapp.com/attachments/1106228797814079488/1106228797986050089/Screenshot_2023-05-11_at_16.37.49.png▾
nutritious-article-48038
05/11/2023, 6:11 PMhttps://cdn.discordapp.com/attachments/1106282480283168838/1106282480442548294/Capture.PNG▾
elegant-insurance-66438
05/11/2023, 8:09 PMcy.session
to login a user and I need to validate the token has been set in local storage, however when using the validate()
method the result from cy.getAllLocalStorage()
does not contain the token item - the login is succesful though as the user is redirected as expected and that test passes. Here is my code.
Cypress.Commands.add("loginViaUi" as any, (user: any) => {
cy.session(
user,
() => {
cy.visit("/public/login");
cy.get("#username").type(user.username, { log: false });
cy.get("#password").type(user.password, { log: false });
cy.get(".ant-btn").click();
},
{
cacheAcrossSpecs: true,
validate: () => {
cy.getAllLocalStorage().then((result) => {
console.log("result", result);
});
},
}
);
});quick-egg-50511
05/12/2023, 5:47 AMplain-potato-68806
05/12/2023, 8:00 AMjavascript
Given("I am a customer", () => {
cy.log("INFO: User Login");
initilizeRun();
});
Is there any way for me to call this step when the cucumber step definition is slightly different or I need to combine multiple steps?quaint-airplane-96634
05/12/2023, 8:43 AMThe content-type of the response we received from your web server was:
application/pdf
This was considered a failure because responses must have content-type: 'text/html'
https://cdn.discordapp.com/attachments/1106501858278785044/1106501858509455370/image.png▾
elegant-insurance-66438
05/12/2023, 10:37 AMhttps://cdn.discordapp.com/attachments/1106530498148319314/1106530498307686420/Screenshot_2023-05-12_at_12.32.36.png▾
steep-belgium-18144
05/12/2023, 12:32 PMadamant-beard-17074
05/12/2023, 5:43 PMfamous-dress-70846
05/12/2023, 6:35 PMhttps://cdn.discordapp.com/attachments/1106650790766067823/1106650790996742295/image.png▾
https://cdn.discordapp.com/attachments/1106650790766067823/1106650791252598844/image.png▾
https://cdn.discordapp.com/attachments/1106650790766067823/1106650791516848151/image.png▾
gray-beard-8992
05/12/2023, 9:37 PMastonishing-actor-1092
05/13/2023, 7:21 AMboundless-needle-41679
05/13/2023, 4:50 PMhttps://cdn.discordapp.com/attachments/1106986918807347381/1106986919033843842/Screenshot_from_2023-05-13_22-17-48.png▾
https://cdn.discordapp.com/attachments/1106986918807347381/1106986919365202031/Screenshot_from_2023-05-13_22-19-27.png▾
colossal-table-38461
05/14/2023, 9:03 AMcold-carpet-69043
05/15/2023, 1:00 AMprehistoric-television-46163
05/15/2023, 6:16 AMabundant-architect-46477
05/15/2023, 8:01 AMfierce-nail-97204
05/15/2023, 11:25 AMincalculable-ability-58905
05/15/2023, 12:01 PMpowerful-gigabyte-69168
05/15/2023, 2:15 PMWarning: It looks like you are trying to record this run from a forked PR.
The Record Key is missing. Your CI provider is likely not passing private environment variables to builds from forks.
These results will not be recorded.
This error will not alter the exit code.
Is there a standard approach to this setup i.e. where tests run in CI using github actions and get recorded in cypress cloud such that test-runs triggered by forks are recorded successfully? I could include the record key in the source code but this seems unideal as I'd prefer to only record the test runs that correspond to PR's against the main repo itselfadorable-insurance-32249
05/15/2023, 3:03 PMhttps://cdn.discordapp.com/attachments/1107684717815418971/1107684717970600096/Screen_Shot_2023-05-15_at_09.28.55.png▾
gorgeous-kitchen-56640
05/15/2023, 4:53 PMvisit
command is started (whichever comes first).
The issue is that, in order to output to the stdout, I am using cy.task('log', ...)
, a pretty familiar pattern, I'm sure, since it's outlined in Cypress' own docs for cy.task
. When this command is run within the context of a cy.visit
command, it gives me this error: Cypress detected that you returned a promise from a command while also invoking one or more cy commands in that promise.
(outlined here: https://docs.cypress.io/guides/references/error-messages#Cypress-detected-that-you-returned-a-promise-from-a-command-while-also-invoking-one-or-more-cy-commands-in-that-promise). There are no promises being used anywhere, so I figure the mere usage of cy.task
is a violation.
To me, this would indicate that there's actually no safe way to output to stdout from within the context of a command, which seems like a major shortcoming of the interface. But I'm sure I'm missing something.
Example code:
// plugins code
...
on('task', {
log(message) {
// eslint-disable-next-line no-console
console.log(message);
return null;
},
...
// func that logs to cy.task
function someFunc() {
cy.task('log', 'log to stdout');
}
// func that overwrites visit
Cypress.Commands.overwrite(
'visit',
(originalFn, url, options) => {
someFunc();
return originalFn(url, options);
}
);
freezing-activity-66869
05/15/2023, 6:12 PMfreezing-activity-66869
05/15/2023, 6:24 PMfreezing-activity-66869
05/15/2023, 9:13 PM