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

feat(check): introduce page.check/uncheck #826

Merged
merged 1 commit into from
Feb 4, 2020

Conversation

pavelfeldman
Copy link
Member

No description provided.

src/dom.ts Outdated

private async _setChecked(state: boolean) {
const isCheckboxChecked = async (): Promise<boolean> => {
return this.evaluate((node: Node) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use this._evaluateInUtility.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -405,4 +405,41 @@ module.exports.describe = function({testRunner, expect, playwright, FFOX, CHROMI
expect(await page.evaluate('document.querySelector("#button").style.left')).toBe('0px');
});
});

describe('Page.check', function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should follow up with checking radio buttons (IIRC, WebDriver does it).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added radio into the mix

expect(await page.evaluate(() => checkbox.checked)).toBe(false);
});
it('should check the box by label', async({page}) => {
await page.setContent(`<label for='checkbox'><input id='checkbox' type='checkbox'></input></label>`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add the following tests?

Checkbox not inside the label:
<label for='checkbox'>Text</label><div><input id='checkbox' type='checkbox'></input></div>

Checkbox inside a label without for=.
<label>Text<span><input id='checkbox' type='checkbox'></input></span></label>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

docs/api.md Outdated
- `selector` <[string]> A selector to search for checkbox to check. If there are multiple elements satisfying the selector, the first will be checked.
- `options` <[Object]>
- `waitFor` <"visible"|"hidden"|"any"|"nowait"> Wait for element to become visible (`visible`), hidden (`hidden`), present in dom (`any`) or do not wait at all (`nowait`). Defaults to `visible`.
- `timeout` <[number]> Maximum navigation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) method.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove "navigation"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

@dgozman dgozman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonderful!

@pavelfeldman pavelfeldman merged commit e3e2da3 into microsoft:master Feb 4, 2020
@pavelfeldman pavelfeldman deleted the check branch April 17, 2020 21:11
sand4rt pushed a commit to sand4rt/playwright that referenced this pull request Dec 21, 2022
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 this pull request may close these issues.

3 participants