Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

189
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda