Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Anna Keesman committed Feb 27, 2024
1 parent 63a253e commit c1e4112
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 16 deletions.
16 changes: 0 additions & 16 deletions cypress/e2e/Webdriver/mouse-actions-js

This file was deleted.

40 changes: 40 additions & 0 deletions cypress/e2e/Webdriver/mouse-actions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
///<reference types="Cypress" />

describe("Test mouse actions ", () => {


it('Scroll element into view', () => {
cy.visit("/");
cy.get('#actions').scrollIntoView().invoke("removeAttr", "target").click({ force: true });

});

it('I should be able to drag and drop a draggable item', () => {
cy.visit("/");
cy.get('#actions').scrollIntoView().invoke("removeAttr", "target").click({ force: true });
cy.get('#draggable').trigger('mousedown', {which: 1})
cy.get('#droppable').trigger('mousemove').trigger('mouseup', {force: true})

});
it('I should be able to perform a double mouse click', () => {
cy.visit("/");
cy.get('#actions').scrollIntoView().invoke("removeAttr", "target").click({ force: true });
cy.get( '#double-click').dblclick()


});
it('I should be able to hold down the left mouse click button on a given item', () => {
cy.visit("/");
cy.get('#actions').scrollIntoView().invoke("removeAttr", "target").click({ force: true });
cy.get( '#click-box').trigger('mousedown', {which: 1}).then(($element) => {
expect($element).to.have.css('background-color', 'rgb(0, 255, 0)')
})


});




});

72 changes: 72 additions & 0 deletions cypress/e2e/Webdriver/traversing-elements.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/// <reference types="Cypress" />
describe("Traversing DOM elements in Cypress", () => {
beforeEach(() => {
cy.visit("http://webdriveruniversity.com/");
cy.get("#data-table").invoke("removeAttr", "target").click({ force: true });
})
it("children() to get the children of DOM elements", () => {
cy.get(".traversal-breadcrumb").children('.active').should('contain', "Contact Us")
});

it("closest() to validate the closest ancestor DOM element", () => {
cy.get('.traversal-badge').closest('ul').should('have.class', 'list-group')
});

it("eq() to retrieve a specific element based on index", () => {
cy.get('.traversal-drinks-list > *').eq(2).should('contain', 'Milk')
});

it("filter() to retrieve DOM elements that match a specific selector", () => {
cy.get('.btn-group-toggle> *').filter('.active').should('contain', 'Button-1')

});

it("find() to retrieve DOM elements of a given selector", () => {
cy.get('.traversal-pagination').find('li').find('a').should('have.length', 7)
});

it("first() to retrieve the first DOM element within elements ", () => {
cy.get('.traversal-table > tbody > tr > td').first().should('contain', 'Andy')
});

it("last() to retrieve the last DOM element within elements", () => {
cy.get('.traversal-table > tbody > tr > td').last().should('contain', 'Scott')
});

it("nextAll() to get all of the next sibling DOM elements within elements", () => {
cy.get('.traversal-drinks-list').contains('Tea').nextAll().should('have.length', 3)
})

it("nextUntil() to get all of the next sibling DOM elements within elements until another element", () => {
cy.get('#coffee').nextUntil('#milk')
});

it("not() to remove DOM element(s) from the set of elements", () => {
cy.get('.traversal-button-states > button').not('.disabled').should('not.have.class', 'disabled')
});

it("parent() To get parent DOM element of elements", () => {
cy.get('.traversal-mark').parent().should('contain', 'Lorem ipsum dolor sit amet')
});

it("parents() to get parents DOM element of elements", () => {
cy.get('.traversal-cite').parents().should('match', 'blockquote')
});

it("prev() to get the previous sibling DOM element within elements", () => {
cy.get('#sugar').prev().contains('Espresso')
});

it("prevAll() to get all previous sibling DOM elements within elements", () => {
cy.get('.sales').prevAll().should('have.length', 2)
});

it("prevUntil() to get all previous sibling DOM elements within elements until other element", () => {
cy.get('#veggie').prevUntil('#fruits').should('have.length', 5)
});

it("siblings() To get all sibling DOM elements of elements", () => {
cy.get('.traversal-button-other-states .active').siblings().should('have.length', 3)
});
})

0 comments on commit c1e4112

Please sign in to comment.