Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to pass the value optained from html block to the writeFile command

This is my first time working in javascript and cypress, so I am a bit unfamiliar with the syntax, I don’t know how to extract the price and write it in a document or in the command log

cy.get('.product-page-pricing > :nth-child(1) > .d-inline-flex > .pricing-block > .product-new-price').then(price).writeFile('C:\path\price_cheking_on_emag_tablet\cypress\e2e\price_history.txt',price)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can do something like this:

cy.get(
  '.product-page-pricing > :nth-child(1) > .d-inline-flex > .pricing-block > .product-new-price'
)
  .invoke('text')
  .then((price) => {
    cy.writeFile('cypress/e2e/price_history.txt', price)
  })
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading