I want to run same test for the same web page for different combinations. Therefore I'm planning to created different scenarios in same feature file or different files. I have already tried passing login details as parameters from feature file but when I try pass JSON file name read data inside of the file, this process fails to do so.
Note : I don't want to loop through different set of data files. Instead pass each file name through feature file
Below is the code
purchase is the file name
I have added the code below
Feature file
When User Navigate into Record deal screen "purchaseBill"
When User select dealer
DealTest.spec.js
var testData;
When ('User Navigate into Record deal screen {string}', (jsonFileName) => {
cy.fixture(jsonFileName).then(function(jsonData){
testData = jsonData
})
cy.log('Dealer name should be in the log as this ----> '+ testData.dealerCode)
recordDealPage.validateDealMenu()
})
When ('User select dealer', (testData) => {
recordDealPage.selectDealer(testData.dealerCode)
cy.log('Dealer name should be in the log as this inside (inside method) ----> '+
testData.dealerCode)
})
DealPage.spec.js
class RecordDealPage{
selectDealer(testData){
cy.log('Dealer name should be in the log as this ----> '+ test.dealerCode)
cy.get('#dealerCode').type(testData.dealerCode)
cy.wait(2000)
cy.get('#dealerCode').type('{downarrow}').type('{enter}')
}
}
JSON datafile purchase.json
{
"dealerCode": "testDealer",
"customerCode": "Customer1"
}
This is what I get when run the test
I'm using Cypress and Cucumber