Home > Net >  how to pass the value optained from html block to the writeFile command
how to pass the value optained from html block to the writeFile command

Time:07-29

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)

CodePudding user response:

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)
  })
  • Related