Anuj Sachan
Anuj Sachan

Reputation: 45

Cypress form submit to same url

I am testing a form submit with Cypress. My Form action is the same has the current page URL. Once I hit submit it downloads a file. I am facing two issues:

  1. Since my form action URL is the same as the current page URL, after submitting it went on an infinite loop.

    cy.get(urSelector.UserActivityReportForm)
    .then(() => {
        util.clearAndSendKeys(urSelector.FromCalendar, urData.From)
        util.clearAndSendKeys(urSelector.ToCalendar, urData.To)
        util.clearAndSendKeys(
            urSelector.SearchByCategoryTxtBox,
            urData.Category
        )
        util.clickSearchButton()
    })
    .then(() => {
        cy.get(urSelector.DownloadUserReportForm).submit()
    })

enter image description here

  1. How can I Validate the file download is completed?

Upvotes: 0

Views: 420

Answers (1)

camilla stevani
camilla stevani

Reputation: 11

If you have to click a button submit, you can try to find the correct name with the Open Selector Playground,then: cy.get('insert yours button').contains('text of yours button').click({force:true})

Upvotes: 1

Related Questions