Search code examples
automationcypresscypress-component-test-runner

# in cypress, what does it reallmean


I am kind of new to cypress and was wondering if someone can explain how to really use the # when calling for an element, I tried to find some documentation but nothing really useful.

Maybe I was looking at the wrong place? if someone could point me in the right direction. Thanks


Solution

  • I am also new to cypress, but '#foo' is just shorthand for '[id="foo"]'

    Say you have an element

    <ul id="foo" class="bar">
    

    You can address it with #foo

    cy.get('#foo') 
    

    is the same as

    cy.get('[id="foo"]')
    

    This works similar for the class.

    cy.get('.bar')
    

    is the same as

    cy.get('[class="bar"]')
    

    Maybe there is more to it, but that is how I use # and . in selectors