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

[BUG] Input change event on setInputFiles #924

Closed
Sue9445 opened this issue Feb 11, 2020 · 2 comments · Fixed by #1028
Closed

[BUG] Input change event on setInputFiles #924

Sue9445 opened this issue Feb 11, 2020 · 2 comments · Fixed by #1028

Comments

@Sue9445
Copy link

Sue9445 commented Feb 11, 2020

Hi,

setInputFiles not emitting the input change event.

@pavelfeldman
Copy link
Member

It does for me, could you share your use case / code snippet?

@Sue9445
Copy link
Author

Sue9445 commented Feb 14, 2020

Hi,

Here is my code, some sites handle file uploads with change event.

(async () => {
	const pw = require("playwright");

	const browser = await pw.firefox.launch({
		headless: true,
	});

	const context = await browser.newContext({
		ignoreHTTPSErrors: true,
		bypassCSP: true,
		userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0",
		viewport: {
			width: 1920,
			height: 1040,
		}
	});

	const page = await context.newPage();

	page.on("console", msg => {
		console.log(msg.text());
	});

	await page.setContent(`
		<input type=file>
		
		<script>
			document.querySelector('input').addEventListener('change', () => {
				console.log('Changed');
			});

			document.querySelector('input').addEventListener('input', () => {
				console.log('Input');
			});
		</script>
	`);

	const input = await page.$('input[type="file"]');
	await input.setInputFiles(__filename);

	await browser.close();
})();

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

Successfully merging a pull request may close this issue.

2 participants