Thanks for the reply. The page was really helpful. My another concern is, is there any way to capture the url of the page and passing it to another test file ? (here my url will be dynamic)
Yes, using cy.url() you can handle it.. Example : 1). For the Other Test File, you can either wrap or write to a file. Below is the sample code with the writeFile solution. Test1: ======= describe('Test for multiple urls', () => { it('Fetch url and save it to the file', () => { cy.visit('naveenautomationlabs.com/opencart/') .get('[title="MacBook"]').click() .url().then((urlvalue) => { cy.writeFile('cypress/fixtures/url.json', { url: urlvalue }); }); }); }) Test2: ======== describe('Fetch URL from Test1', () => { it('pass URL from fixture file', () => { cy.fixture('url').then((urlValue) => { cy.visit(urlValue) }) }); });
Hi Anshita, Im new to k6, i have used the same code on gorest dummy POST api and have passed the bearer token in params as well, theres no error in the code but its returning 401 but same api is working on postman, can u help
Make sure that the token is correct. Check out the sample code for the GoRest API here: github.com/Anshita-Bhasin/k6_examples/blob/main/post-go-rest-api.js
@@ABAutomationHub Hello, noticed i was passing the token directly in params constant without putting it in headers. Thank you for replying, this helped
Hi, I'm new to cypress automation. Here I have a concern like is it possible to capture the text from one test case and pass it to compare it in another test case ? I'm awaiting for your reply.
Yes, it is possible to do it. You can check out the detailed code here : github.com/Anshita-Bhasin/Cypress_Examples/blob/main/cypress/e2e/findText.cy.js medium.com/@anshita.bhasin/how-to-get-element-text-in-cypress-71c68814d20
amazing !!! thanks!
Thanks for the reply. The page was really helpful.
My another concern is, is there any way to capture the url of the page and passing it to another test file ? (here my url will be dynamic)
Yes, using cy.url() you can handle it..
Example :
1). For the Other Test File, you can either wrap or write to a file. Below is the sample code with the writeFile solution.
Test1:
=======
describe('Test for multiple urls', () => {
it('Fetch url and save it to the file', () => {
cy.visit('naveenautomationlabs.com/opencart/')
.get('[title="MacBook"]').click()
.url().then((urlvalue) => {
cy.writeFile('cypress/fixtures/url.json', { url: urlvalue });
});
});
})
Test2:
========
describe('Fetch URL from Test1', () => {
it('pass URL from fixture file', () => {
cy.fixture('url').then((urlValue) => {
cy.visit(urlValue)
})
});
});
Hi Anshita, Im new to k6, i have used the same code on gorest dummy POST api and have passed the bearer token in params as well, theres no error in the code but its returning 401 but same api is working on postman, can u help
Make sure that the token is correct. Check out the sample code for the GoRest API here: github.com/Anshita-Bhasin/k6_examples/blob/main/post-go-rest-api.js
@@ABAutomationHub Hello, noticed i was passing the token directly in params constant without putting it in headers. Thank you for replying, this helped
Hi, I'm new to cypress automation. Here I have a concern like is it possible to capture the text from one test case and pass it to compare it in another test case ? I'm awaiting for your reply.
Yes, it is possible to do it. You can check out
the detailed code here : github.com/Anshita-Bhasin/Cypress_Examples/blob/main/cypress/e2e/findText.cy.js
medium.com/@anshita.bhasin/how-to-get-element-text-in-cypress-71c68814d20