cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.72k stars 3.16k forks source link

Feat. Request: Auto copy selector from playground && || Record user interactions directly into spec file #2385

Closed sf-jd closed 5 years ago

sf-jd commented 6 years ago

Current behavior:

No auto copy to clipboard from selector playground seems to exist. No recording of user actions seems to exist.

Desired behavior:

Auto copy selector from playground:

It would be cool that when I select an element from the selector playground, that it gets auto copied to clipboard. This could speed up the script generation. Just select the element, then alt tab into my editor and paste it.

Record user interactions into spec file

If I have my It blocks predefined in my spec file, I could see them somewhere in the CypressUI (mayhaps a dropdown?) and upon selecting it and enabling "track steps" I could do my flow and automatically have the selectors and interactions be copied into that particular it block.

Lets suppose i have an empty spec

context('testing spec', ()=>{
  it('should be completed', ()=>{
    cy.visit(myappurl)
  })
})

Then, I go into Cypress and select the 'should be completed' test from my available specs. After this, I launch the test and I interactively do the flow, and it gets "recorded" so my job is now to clean up the actions that got automatically added to my test if at all required.

Ideally, if I have a simple app with a button that will toggle a div visibility I would

1- Click on the button 2- Assert that the div is visible 3- Click on the button again 4- Assert the div is no longer visible

After following the steps, my spec file would look like:

context('testing spec', ()=>{

  it('should be completed', ()=>{
    cy.visit(myappurl)
    cy.get(button).click()
    cy.get(div).should('be.visible')
    cy.get(button).click()
    cy.get(div).should('not.be.visible')
  })
})

If writing the .spec.js file is not an option, perhaps a popup/section within the cypressUi that lists the user steps that were recorded?

jennifer-shehane commented 5 years ago

Duplicate of https://github.com/cypress-io/cypress/issues/73