Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple teststoMatchSnapShots #127

Open
FaresAbderrazag opened this issue Mar 8, 2019 · 0 comments
Open

Multiple teststoMatchSnapShots #127

FaresAbderrazag opened this issue Mar 8, 2019 · 0 comments

Comments

@FaresAbderrazag
Copy link

FaresAbderrazag commented Mar 8, 2019

I want to recover several screenshots in separate tests
like this
capture d ecran 2019-03-08 a 10 28 40 1

`const Differencify = require('differencify');
const differencify = new Differencify({ debug: true });

// Takes a screenshot, compares
async function screenshotAndCompares (page, target) {
const image = await page.screenshot();
await target.toMatchSnapshot(image);

};

describe('tests', () => {

	beforeAll(async () => {
	await differencify
		.launchBrowser();
	});
	afterAll(async () => {
		await differencify.cleanup();
	});



	it('test 1', async () => {

		const target = differencify.init({ chain: false });
		await target.launch();
		const page = await target.newPage();
		await page.setViewport({ width: 400, height: 600 });

		// URL : does not change from one page to another 
		//			 we advance from one page to another by clicking on a button 
		await page.goto('https://Mypage.com')


		await page.waitForSelector('#homePage');
		await page.waitFor(1000)

		// Takes a screenshot, compares
		await screenshotAndCompares(page, target);

	}, 60 * 1000); // 60 is the timeout in seconds




	it('test 2', async () => {


		/*
		here I must continue the course I must not start from the beginning
			example:
			test 1 = 	- go to https://Mypage.com
					- take screenshot of the home page of my web page

			test 2 = 	- connect to the application
				        - take a screenshot of the welcome page of the application

		         test 3 = 	- click on start
					- Take in screenshot the question page 1

			test 4 = 	- click next
					- take in screenshot the question page 2
		*/


		// connect to the application
		//you can log in only once with the same email adresse and at each connection you start from the beginning
		await page.waitForSelector('#input_login');
		await page.click('#input_login');
		await page.type('#input_login', 'Tests@tests.com'); 
		await page.waitForSelector('#button_login');
		await page.click('#button_login');


		// Takes a screenshot, compares
		await screenshotAndCompares(page, target);

	}, 60 * 1000); // 60 is the timeout in seconds





	it('test 3', async () => {


		//click on start : directs you to the question page 1
		await page.waitForSelector('#button_start');
		await page.click('#button_start');

		// Takes a screenshot, compares
	await screenshotAndCompares(page, target);

	}, 60 * 1000); // 60 is the timeout in seconds

	
	it('test 4', async () => {


		//click on next : directs you to the question page 2
		await page.waitForSelector('#button_next');
		await page.click('#button_next');

		// Takes a screenshot, compares
	await screenshotAndCompares(page, target);
	
	}, 60 * 1000); // 60 is the timeout in seconds

	//close page

});

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants