Skip to content

Instantly share code, notes, and snippets.

@dariayermolova
dariayermolova / cypress (mock file)
Created January 21, 2020 14:17
cypress (mock file)
cy.server()
cy.route({
url: '/users?approved=true',
status: 200,
response: 'fixture:empty.user.json'
}).as('approved')
@dariayermolova
dariayermolova / cypress (mock)
Created January 21, 2020 14:11
cypress (mock)
await cy.server();
await cy.route({
method: 'POST',
url: 'users',
response: {name: 'mocked user'}
});
await cy.addUser();
@dariayermolova
dariayermolova / cypress (check response2)
Created January 21, 2020 13:49
cypress (check response2)
cy.server();
cy.route(url:'POST', response:'/users').as(alias:'addUser');
cy.wait(alias:'@addUser').should((xhr) => {
expect(xhr.responseBody).to.include('name')
})
@dariayermolova
dariayermolova / cypress (check response)
Created January 21, 2020 13:48
cypress (check response)
cy.server();
cy.route(url:'POST', response:'/users').as(alias:'addUser');
cy.wait(alias:'@addUser').should((xhr) => {
expect(xhr.responseBody.name).to.eq('name')
})
@dariayermolova
dariayermolova / cypress (check response)
Created January 21, 2020 13:48
cypress (check response)
cy.server();
cy.route(url:'POST', response:'/users').as(alias:'addUser');
cy.wait(alias:'@addUser').should((xhr) => {
expect(xhr.responseBody.name).to.eq('name')
})
@dariayermolova
dariayermolova / cypress (upload file)
Created January 21, 2020 13:42
cypress (upload file)
import 'cypress-file-upload';
Cypress.Commands.add('uploadFile', (fileName, input, mime) => {
cy.fixture(fileName).then(fileContent => {
cy.get(input).upload(
{ fileContent, fileName, mimeType: mime },
{ subjectType: 'input' },);
});
})
@dariayermolova
dariayermolova / cypress (check status of response)
Created January 21, 2020 13:40
cypress (check status of response)
cy.server()
cy.route({
method: 'POST',
url: '/authenticate?'
}).as('loginApi')
cy.wait('@loginApi').its('status').should('eq', 200).then(() => {
cy.url().should('include', '/home')
})
var moment = require("moment");
pm.environment.set('start', moment().add(30, 'minutes').format('YYYY-MM-DD HH:mm:00'));
///or
pm.environment.set('end', moment().add(45, 'minutes').toISOString());
public boolean scrollPageDown() {
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("window.scrollBy(0,250)");
boolean scrollResult = (boolean) executor.executeScript {
"var scrollBefore = $(window).scrollTop();" +
"window.scrollTop(scrollBefore, document.body.scrollHeight);" +
"return $(window).scrollTop() > scrollBefore;"};
return scrollResult;
}
pm.test("responce contains billing_type", function () {
pm.expect(jsonData.billing_type).to.eql("check");
});