-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Conversation
src/dom.ts
Outdated
|
||
private async _setChecked(state: boolean) { | ||
const isCheckboxChecked = async (): Promise<boolean> => { | ||
return this.evaluate((node: Node) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use this._evaluateInUtility
.
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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>`); |
There was a problem hiding this comment.
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>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove "navigation"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonderful!
No description provided.