Radio button:
await page.locator("locator").check()
await page.check("locator")
to check whether the radio button is checked or not:
const status = await page.locator("locator")
await page.expect(status).toBeChecked()
await page.expect(await page.locator("locator").isChecked()).toBeTruthy()
//isChecked() give true or false
Checkbox: same method and process for Checkbox, but we can select more than one checkbox. Select multiple checkboxes: create an array of XPath strings and loop through it.
const checkboxLocators = ["", ""]
for(locator of checkboxLocators) await page.locator(locator).check()
//unselect the multiple checkbox which are already checked
for(locator of checkboxLocators){
if(await page.locator(locator).isChecked()) {
await page.locator(locator).uncheck()
}
}
await page.waitForTimeout(5000)
scroll: page.mouse.wheel(0,5000)
mouse hover:
const h1 = locator
const h2 = locator
await h1.hover()
await h2.hover()
Right-click:
await locator.click({button:"right"})
Double click:
await locator.dblclick()
Keyboard keys: Syntax: page.keyboard.press():combination of keys(ctrl+a)
await page.keyboard.press("Control+A") - select the text.
await page.keyboard.press("Control+C") - copy the text.
//copy and paste the text:
await page.keyboard.press("Control+A")
await page.keyboard.press("Control+C")
await page.keyboard.down("Tab")
await page.keyboard.up("Tab")
await page.keyboard.press("Control+V")