diff --git a/lib/ElementHandle.js b/lib/ElementHandle.js
index 3a70676fe09..aabdbb6d646 100644
--- a/lib/ElementHandle.js
+++ b/lib/ElementHandle.js
@@ -75,7 +75,7 @@ class ElementHandle extends JSHandle {
/**
* @param {!Object=} options
*/
- async click(options) {
+ async click(options = {}) {
const {x, y} = await this._visibleCenter();
await this._page.mouse.click(x, y, options);
}
diff --git a/lib/Page.js b/lib/Page.js
index e55e0a1dfef..0cb6de7f7a6 100644
--- a/lib/Page.js
+++ b/lib/Page.js
@@ -750,9 +750,9 @@ class Page extends EventEmitter {
/**
* @param {string} selector
- * @param {!Object} options
+ * @param {!Object=} options
*/
- async click(selector, options) {
+ async click(selector, options = {}) {
const handle = await this.$(selector);
console.assert(handle, 'No node found for selector: ' + selector);
await handle.click(options);
diff --git a/test/assets/input/checkbox.html b/test/assets/input/checkbox.html
new file mode 100644
index 00000000000..ca56762e2b3
--- /dev/null
+++ b/test/assets/input/checkbox.html
@@ -0,0 +1,42 @@
+
+
+
+ Selection Test
+
+
+
+
+
+
+
diff --git a/test/test.js b/test/test.js
index f311be261d9..cdcfc282bb7 100644
--- a/test/test.js
+++ b/test/test.js
@@ -1845,6 +1845,38 @@ describe('Page', function() {
await page.click('button');
expect(await page.evaluate(() => result)).toBe('Clicked');
}));
+
+ it('should click on checkbox input and toggle', SX(async function() {
+ await page.goto(PREFIX + '/input/checkbox.html');
+ expect(await page.evaluate(() => result.check)).toBe(null);
+ await page.click('input#agree');
+ expect(await page.evaluate(() => result.check)).toBe(true);
+ expect(await page.evaluate(() => result.events)).toEqual([
+ 'mouseover',
+ 'mouseenter',
+ 'mousemove',
+ 'mousedown',
+ 'mouseup',
+ 'click',
+ 'change',
+ ]);
+ await page.click('input#agree');
+ expect(await page.evaluate(() => result.check)).toBe(false);
+ }));
+
+ it('should click on checkbox label and toggle', SX(async function() {
+ await page.goto(PREFIX + '/input/checkbox.html');
+ expect(await page.evaluate(() => result.check)).toBe(null);
+ await page.click('label[for="agree"]');
+ expect(await page.evaluate(() => result.check)).toBe(true);
+ expect(await page.evaluate(() => result.events)).toEqual([
+ 'click',
+ 'change',
+ ]);
+ await page.click('label[for="agree"]');
+ expect(await page.evaluate(() => result.check)).toBe(false);
+ }));
+
it('should fail to click a missing button', SX(async function() {
await page.goto(PREFIX + '/input/button.html');
let error = null;