Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cypress: How to check button url?

Tags:

url

cypress

I want to check that buttons urls are contain specific urls (without clicking on them), is it possible?

like image 699
Damian Małecki Avatar asked Mar 25 '19 21:03

Damian Małecki


People also ask

How do you check if a button is clickable in Cypress?

You can use the jquery enabled selector to check whether the button is enabled or not and based on that perform other actions.

What is the Cypress command to open an URL of the webpage?

visit() . By default, the cy. visit() commands' will use the pageLoadTimeout and baseUrl set globally in your configuration. The URL to visit.


1 Answers

Check out the list of supported assertions: https://docs.cypress.io/guides/references/assertions.html#Chai

You can use have.attr to test the href attribute of an <a> tag.

For example:

cy.get('a.my-link').should('have.attr', 'href', 'https://example.com')
like image 159
Zach Bloomquist Avatar answered Oct 06 '22 20:10

Zach Bloomquist