function switchCase(event: EventObj): string {
let { selector, action, input, URL, a, href} = event;
if (a == true){
action = 'navigate'
}
switch (action) {
case 'click':
return `cy.xpath('${selector}').should('exist');
cy.xpath('${selector}').click({force:true});`;
break;
case 'change':
return `cy.xpath('${selector}').type('${input}');`;
break;
case 'navigate':
return `cy.xpath('${selector}').click();
cy.location('pathname').should('eq','${href}');`;
break;
case 'assertion':
let finalText = '';
finalText += `cy.xpath('${selector}').should('exist');`
// if contains a inner text or outerText
if (href){
finalText += `cy.xpath('${selector}').contains("a").should("have.attr", "href", "${href}");`
}
if (input.innerHTML !== '' && input.innerHTML){
finalText += `cy.xpath('${selector}').should('have.html',${JSON.stringify(input.innerHTML)}).and('be.visible');`
}
if (input.id !== '' && input.id){
finalText += `cy.xpath('${selector}').should('have.id', '${input.id}');`
}
if (input.className !== '' && input.className){
finalText += `cy.xpath('${selector}').should('have.attr', '${input.className}');`
}
return finalText;
default:
return 'didnt input a valid action';
}
}