Keyboard and mouse interactions, powered by Selenium’s Actions class, enable testing advanced user behaviors like drag-and-drop, mouse hover, and keyboard events, boosting test coverage and accuracy.
Actions class?Actions class in Selenium?Actions action = new Actions();Actions action = new Actions(driver);action.start(driver);action.create(driver);perform() method do in the Actions class?Actions class?clickAndHold()release()dragAndDrop()scrollTo()Actions class is part of which Selenium package?org.openqa.selenium.actionsorg.openqa.selenium.interactionsorg.openqa.selenium.mouseorg.openqa.selenium.toolsdragAndDrop() in Selenium?moveByOffset()moveToElement()hoverElement()scrollToElement()action.dragAndDrop(source, target).perform();action.drag(source).drop(target).perform();action.move(source).click(target).perform();action.moveTo(source, target).perform();dragAndDrop()?clickAndHold().moveToElement().release().perform()select().move().release()drag().drop().perform()click().move().drop()moveByOffset(x, y)dragAndDropBy(x, y)scrollByOffset(x, y)moveToOffset(x, y)clickAndHold()release()selectMultiple()dragMultiple()dragAndDropBy(), what do the x and y parameters specify?contextClick()rightClick()clickRight()doubleClick()moveToElement() method do?keyDown()pressKey()sendKey()simulateKey()keyUp()releaseKey()stopKey()clearKey()sendKeys() accept?Shift key while entering text?keyDown(Keys.SHIFT).sendKeys("text").keyUp(Keys.SHIFT).perform();press(Keys.SHIFT).sendKeys("text").release(Keys.SHIFT).perform();shiftDown().sendKeys("text").shiftUp().perform();sendKeys(Keys.SHIFT, "text").perform();Ctrl+C) in Selenium?keyDown(Keys.CONTROL).sendKeys("C").keyUp(Keys.CONTROL).perform();sendShortcut(Keys.CONTROL, "C").perform();sendKeys(Keys.CONTROL, "C").perform();keyPress(Keys.CONTROL, "C").perform();sendKeys(Keys.TAB)?sendKeys(Keys.BACKSPACE)keyDown(Keys.DELETE)keyPress(Keys.REMOVE)removeKey(Keys.BACKSPACE)Ctrl+A)?keyDown(Keys.CONTROL).sendKeys("A").keyUp(Keys.CONTROL).perform();sendKeys(Keys.CONTROL + "A").perform();sendShortcut("Ctrl", "A").perform();press(Keys.CONTROL + "A").perform();sendKeys(Keys.ENTER)keyDown(Keys.RETURN)keyPress(Keys.ENTER)pressKey(Keys.SUBMIT)keyDown(Keys.CONTROL) method do?keyUp(Keys.SHIFT)releaseKey(Keys.SHIFT)stopShift(Keys.SHIFT)shiftRelease(Keys.SHIFT)keyDown(Keys).sendKeys().keyUp(Keys).perform()combineKeys(Keys).perform()sendKeys(Keys.COMBINE).perform()multiKeySend(Keys).perform()sendKeys("text")type("text")enterText("text")insertText("text")sendKeys(Keys.SPACE)keyPress(Keys.BLANK)sendKeys(Keys.BLANK)pressKey(Keys.SPACE)sendKeys(Keys.TAB)keyPress(Keys.ESC)clearFocus()sendKeys(Keys.RELEASE)Keyboard and Mouse Actions in Selenium:
| QNo | Answer (Option with the text) |
|---|---|
| 1 | b) To automate mouse and keyboard actions |
| 2 | b) Actions action = new Actions(driver); |
| 3 | a) Executes the stored actions |
| 4 | d) scrollTo() |
| 5 | b) org.openqa.selenium.interactions |
| 6 | a) Moves an element to a target location |
| 7 | b) moveToElement() |
| 8 | a) action.dragAndDrop(source, target).perform(); |
| 9 | a) clickAndHold().moveToElement().release().perform() |
| 10 | a) moveByOffset(x, y) |
| 11 | a) The element must be visible |
| 12 | a) clickAndHold() |
| 13 | a) The number of pixels to drag |
| 14 | a) contextClick() |
| 15 | a) Moves the mouse cursor to the specified element |
| 16 | a) keyDown() |
| 17 | a) keyUp() |
| 18 | a) A sequence of characters or keys |
| 19 | a) keyDown(Keys.SHIFT).sendKeys("text").keyUp(Keys.SHIFT).perform(); |
| 20 | a) keyDown(Keys.CONTROL).sendKeys("C").keyUp(Keys.CONTROL).perform(); |
| 21 | a) Simulates a tab key press for navigation |
| 22 | a) sendKeys(Keys.BACKSPACE) |
| 23 | a) keyDown(Keys.CONTROL).sendKeys("A").keyUp(Keys.CONTROL).perform(); |
| 24 | a) sendKeys(Keys.ENTER) |
| 25 | a) Simulates holding down the Ctrl key |
| 26 | a) keyUp(Keys.SHIFT) |
| 27 | a) keyDown(Keys).sendKeys().keyUp(Keys).perform() |
| 28 | a) sendKeys("text") |
| 29 | a) sendKeys(Keys.SPACE) |
| 30 | a) sendKeys(Keys.TAB) |