My code is:
import {agentList} from '../pageObjects/agent-list';
class AgentProfile {
constructor() {
this.agentNameExpect = () => cy.get('.col-lg-6:nth-child(1)')
this.firstLastNameExpect = () => cy.get('tbody > :nth-child(1) > :nth-child(2) > a')
this.editInformationBtn = () => cy.get('[data-action="edit-info"]')
this.firstNameEdit = () => cy.get('#agent_info_user_first')
this.lastNameEdit = () => cy.get('#agent_info_user_last')
this.dbaNameEdit = () => cy.get('#agent_info_dbaName').as('dban')
}
typeField(nameField, test) {
this.editInformationBtn()
.click();
// How can I use different locators (this.firstNameEdit, this.lastNameEdit, this.dbaNameEdit e.t.c.) to make the method 'typeField' universal?
// It doesn`t works below
cy.get(nameField)
// or It doesn`t works too
this.(nameField)
// or It is not universal method
this.dbaNameEdit()
.clear()
.type(test)
this.saveBtn()
.click()
};
}
export const agentProfile = new AgentProfile;