Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

186
Vistas
How to read values from input.json file into gherkin feature file in cypress

My Feature file :

Feature: Login page

Feature Login page will work depending on the user credentials.

Background: 
    Given A user opens a saucelabs website
Scenario: Success Login 
    When A user enters the username "standard_user"
    And A user enters the password "secret_sauce"
    And A user clicks on the login button
    Then the url will contains the /inventory subdirectory

Input file :sauceCreds.json { "standardUserName":"standard_user", "systempwd":"secret_sauce", }

My class file :

class homeSaucePage{

elements = {
    usernameInput: () => cy.get('#user-name'),
    passwordInput: () => cy.get('#password'),
    loginBtn: () => cy.get('#login-button'),
    errorMessage: () => cy.get('h3[data-test="error"]')
}

typeUsername(username){
    this.elements.usernameInput().type(username);
}

typePassword(password){
    this.elements.passwordInput().type(password);
}

clickLogin(){
    this.elements.loginBtn().click();
}

}

module.exports = new homeSaucePage();

Stepdefinition file :

import {Given, When, And, Then} from 'cypress-cucumber-preprocessor/steps'
const loginPage = require('../../pages/loginPage')

beforeEach(function () {
    cy.fixture('sauceCreds').then(function (credentials) {
     this.credentials = credentials;
    })
  })

Given('A user opens a saucelabs website', () => {
     cy.visit('https://www.saucedemo.com/')
    
})
When('A user enters the username {string}', function() {
    loginPage.typeUsername(this.credentials.standardUserName)
})

I want to access the json input file from feature file and want to achieve something like this

My Feature file :

Feature: Login page

Feature Login page will work depending on the user credentials.

Background: 
    Given A user opens a saucelabs website
Scenario: Success Login 
    When A user enters the username sauceCreds.json.standard_user
    And A user enters the password sauceCreds.json.systempwd
    And A user clicks on the login button
    Then the url will contains the /inventory subdirectory
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda