Action class is used to handle keyboard
events and mouse actions. Further this class is also used to chain
actions or perform multiple actions.
Action name | Parameters | Description |
click | WebElement | This is used to click in the middle of the element passed as parameter. Like action.click(webelement) |
click | No Parameter | This is used to click at the current location. It is used with combination of actions. Like action.moveToElement(org.openqa.selenium.WebElement, int, int).click() or action.moveByOffset(int, int).click() |
doubleClick | WebElement | This is used to double click in the middle of the element passed as parameter. Like action.doubleClick(webelement) |
doubleClick | No Parameter | This is used to double click at the current location. It is used with combination of actions. Like action.moveToElement(org.openqa.selenium.WebElement, int, int).doubleClick() or action.moveByOffset(int, int).doubleClick() |
moveToElement | WebElement | This is used to move mouse pointer to the middle of webelement passed as parameter. The element is scrolled into view. Like action.moveToElement(webelement) |
moveToElement | WebElement, int, int | This is used to move the mouse pointer to offsets from the top left corner of element.The element is scrolled into view. Example: action.moveToElement(webelement, int, int) |
moveByOffset | int, int | This is used to move mouse pointer from current position to the provided offsets. Example: action.moveByOffset(int, int) |
keyDown | java.lang.CharSequence | This is used to perform key press. Remember key is not released automatically, Need to call keyUp() or sendKeys() function. Example: action.keyDown(keys.CONTROL) |
keyDown | WebElement, java.lang.CharSequence | This is used to press key at web element. Example: action.keyDown(webelement, keys.CONTROL) |
keyUp | Java.lang.CharSequence | This is used to keup or release key at current location. Example: action.keyUp(keys.CONTROL) |
KeyUp | WebElement, Java.lang.CharSequence | This is used to press up at web element. Example: action.keyUp(webelement, keys.CONTROL) |
sendKeys | java.lang.CharSequence | This is used to send keys on active element. Example: action.sendKeys(Keys.TAB) |
clickAndHold | WebElement | Click on current mouse location without releasing. |
contextClick | WebElement | Right click on web element. Example: action.contextClick(webelement) |
dragAndDrop | WebElement, WebElement | Perform drag and drop from one element to other. |
dragAndDropBy | WebElement, int, int | Perform drag and drop from one element to co-ordinates. |
build | No Parameter | Used to combine multiple actions into single step. Example: Actions oAction=new Actions(driver); Actions moreActions = oAction .moveToElement(element) .click() .keyDown(element,Keys.SHIFT) .sendKeys(element,"selenium"); Action chaining= moreActions.build(); |
perform | No Parameter | For execution of Action object, this method is used. Example: chaining.perform(); |
No comments:
Post a Comment