Add test example to scrap a web page.
This commit is contained in:
94
cypress/e2e/sandbox.cy.js
Normal file
94
cypress/e2e/sandbox.cy.js
Normal file
@@ -0,0 +1,94 @@
|
||||
// describe('template spec', () => {
|
||||
// it('passes', () => {
|
||||
// cy.visit('https://example.cypress.io')
|
||||
// })
|
||||
// })
|
||||
|
||||
/*
|
||||
function sum(a, b) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
function minus(a, b) {
|
||||
return a - b;
|
||||
}
|
||||
|
||||
const resultatDeUnEtDeux = sum(1, 2);
|
||||
|
||||
const sum2 = (a, b) => {
|
||||
console.log(a + b);
|
||||
};
|
||||
|
||||
Un lambda s'écrit de la manière suivante :
|
||||
(...) => {
|
||||
...
|
||||
}
|
||||
|
||||
sum2(10, 20);
|
||||
|
||||
const x = 3;
|
||||
const y = 2;
|
||||
|
||||
const monOperationArithmetique = sum;
|
||||
|
||||
const result = monOperationArithmetique(x, y);
|
||||
|
||||
console.log(result);
|
||||
|
||||
|
||||
const testName = 'mon premier test';
|
||||
const testCode = () => {
|
||||
console.log('Ça fonctionne !');
|
||||
}
|
||||
it(testName, testCode);
|
||||
*/
|
||||
|
||||
/*
|
||||
class MyService(self):
|
||||
def functionA(self, x):
|
||||
# ...
|
||||
pass
|
||||
|
||||
def functionB(self):
|
||||
pass
|
||||
|
||||
describe('MyService', () => {
|
||||
describe('functionA', () => {
|
||||
it('should return true when user age is under 18', () => {
|
||||
//...
|
||||
});
|
||||
|
||||
it('should return false when user age is lower or equals 18', () => {
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
*/
|
||||
|
||||
// describe('Le site ouest-france-immo', () => {
|
||||
// it('doit se charger dans cypress', () => {
|
||||
// cy.visit('https://www.ouestfrance-immo.com/louer/appartement--2-pieces/rennes-beaulieu-35-35000/?pieces');
|
||||
|
||||
|
||||
// cy.get('.header')
|
||||
// .should('exist');
|
||||
// });
|
||||
|
||||
// });
|
||||
|
||||
describe('Le site codiki.org', () => {
|
||||
it('doit se charger dans cypress', () => {
|
||||
cy.visit('https://codiki.org');
|
||||
|
||||
cy.get('.publication')
|
||||
.each(($div) => {
|
||||
cy.wrap($div).find('div').find('h1').invoke('text').as('h1Text');
|
||||
|
||||
cy.get('@h1Text').then((text) => {
|
||||
//cy.log(text);
|
||||
console.log(text);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user