Mi archivo de características:
Característica: página de inicio de sesión
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 subdirectoryArchivo de entrada :sauceCreds.json { "standardUserName":"standard_user", "systempwd":"secret_sauce", }
Mi archivo de clase:
clase 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(); }}
módulo.exportaciones = nueva homeSaucePage();
Archivo de definición de pasos:
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) })Quiero acceder al archivo de entrada json desde el archivo de funciones y quiero lograr algo como esto
Mi archivo de características:
Característica: página de inicio de sesión
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