Skip to content

Instantly share code, notes, and snippets.

View hypeJunction's full-sized avatar

Ismayil Khayredinov hypeJunction

View GitHub Profile
<label>
Search
<input type="search" value="bear" aria-busy aria-describedby="search-progress" />
</label>
<div role="progressbar" class="spinner" aria-label="Searching for bear" />
<ul aria-label="Search Results" aria-busy aria-describedby="search-progress">
<li>Elephant</li>
</ul>
cy.getInput('Add File').attach('elephant.pdf');
cy.getInput('Add File')
.alerts()
.should('include', 'PDF files are not supported');
cy.getList('File List')
.getListItem('elephant.pdf')
.alerts()
.should('include', 'PDF files are not supported');
<label>
Add File
<input type="file"
accepts="image/*"
aria-invalid
aria-describedby="file-input-help file-2-error"
aria-errormessage="file-2-error"
/>
</label>
<span id="file-input-help">Please add 1 or more image files</span>
cy.getForm('Login').within(() => {
cy.getInput('Username').type('john.doe');
cy.getInput('Password').type('secret');
cy.getButton('Submit').press();
})
cy.getForm('Add To-Do Item').within(() => {
cy.getInput('To-Do Item').type('Buy Milk');
cy.getButton('Add').press();
})
cy.getList('To-Do List').within(() => {
cy.getListItem('Buy Milk').should('exist');
cy.getInput('Buy Milk').check();
});
<div id="list-id">To-Do List</div>
<ul aria-labelledby="list-id">
<li aria-labelledby="item-1">
<label>
<input type="checkbox" />
<span id="item-1">Do Laundry</span>
</label>
</li>
<li aria-labelledby="item-2">
<label>
<form>
<label>Username<input /></label>
<label>Password<input/ ></label>
<button type="submit">Submit</button>
</form>
* I see a "Login" form
* I enter "john.doe" in "Username" input
* I enter "secret" in "Password" input
* I press "Submit" button
cy.getForm('Login');
cy.getInput('Username').type('john.doe');
cy.getInput('Password').type('secret');
cy.getButton('Submit').press();
cy.findByRole('form', { name: 'Login' }).as('landmark');
cy.get('@landmark').findByLabelText('Username').type('johh.doe');
cy.get('@landmark').findByLabelTest('Password').type('secret');
cy.get('@landmark').findByRole('button', { name: 'Submit' }).click();