English 中文(简体)
Cypress - Environment Variables
  • 时间:2024-03-24 09:04:36

Cypress - Environment Variables

Previous Page Next Page  

<<>>>> >> ><>>>>>> >> > > > > > > > > > > > > >项目内“json” 文档。

Cypress JSON

页: 1

页: 1

Implementation in cypress.json

∗∗∗∗


{
   "projectId": "fvbpxy",
   "env" :
   {
      "url" : "https://www.google.com/"
   }
}

Implementation of Actual Test

西欧和其他国家:


describe( Tutorialspoint Test , function () {
   // test case
   it( Scenario 1 , function (){
      // launch apppcation from environment variable
      cy.visit(Cypress.env( url ))
      cy.getCookies()
      cy.setCookie( cookie1 ,  value1 )
   });
});

纽约总部

Output Logs

<> > >

Configure Environment Variables

We can configure or modify the environment values from the command pne with the flag --env.

To run a particular file (for example: Test1.js) with URL: https://accounts.google.com in a headed mode, the command shall be as follows:


./node_modules/.bin/cypress run --spec cypress/integration/examples/Test1.js --
env url=https://accounts.google.com –headed

∗∗∗∗∗∗∗∗

Advertisements