Topic: cypress - lecture 10 - traversal methods - lecture 5

//Regular lecture 36: 15-Nov-2022

//*Topic*//cypress - lecture 10//
//traversal methods: lecture 5

//.closest() - To get the closest ancestor DOM element
//.filter() - To get DOM elements that match a specific selector 
//.find() - To get descendant DOM elements of the selector
//.not() - To remove DOM element(s) from the set of elements

describe("traversal methods", function(){
    
    it(".closest() method", function(){

        cy.visit("http://www.webdriveruniversity.com/Data-Table/index.html")
        cy.get('[id="tea"]').closest('div')

    })

    it(".filter() method", function(){

        cy.visit("http://www.webdriveruniversity.com/Data-Table/index.html")
        cy.get('[class="traversal-drinks-list"]').children().filter('[id="coffee"]')

    })
    
    it(".find() method", function(){

        cy.visit("http://www.webdriveruniversity.com/Data-Table/index.html")
        cy.get('[class="traversal-drinks-list"]').find('[id="milk"]')

    })

    it(".not() method", function(){

        cy.visit("http://www.webdriveruniversity.com/Data-Table/index.html")
        cy.get('[class="traversal-drinks-list"]').children().not('[id="espresso"]')

    })
})


//list of all traversal methods:

//.parent()
//.children()
//.siblings()
//.prev()
//.next()
//.prevAll()
//.nextAll()
//.prevUntil()
//.nextUntil()
//.first()
//.last()
//.parents()
//.parentsUntil()
//.filter()
//.find()
//.closest()
//.not()

टिप्पण्या