Skip to main content

ElementActions

Static methods​

onElement​

This will return IElementActions which will expose different methods to handle all other element actions.

IElementActions elementActions = ElementActions.onElement ();

Instance methods​

getAttribute (attribute)​

This method is used to get the attribute of the given element.

import static io.github.boykaframework.actions.elements.ElementActions.onElement;
. . .
String attribute = onElement (locator).getAttribute ("href");

clear​

This method is used to clear the given element.

import static io.github.boykaframework.actions.elements.ElementActions.onElement;
. . .
onElement (locator).clear ();

isDisplayed​

This method is used to check whether the given element is displayed or not.

import static io.github.boykaframework.actions.elements.ElementActions.onElement;
. . .
boolean displayed = onElement (locator).isDisplayed ();

isEnabled​

This method is used to check whether the given element is enabled or not.

import static io.github.boykaframework.actions.elements.ElementActions.onElement;
. . .
boolean enabled = onElement (locator).isEnabled ();

isSelected​

This method is used to check whether the given element is selected or not.

import static io.github.boykaframework.actions.elements.ElementActions.onElement;
. . .
boolean selected = onElement (locator).isSelected ();

scrollIntoView​

This method will scroll the element into the viewport.

import static io.github.boykaframework.actions.elements.ElementActions.onElement;
. . .
onElement (locator).scrollIntoView ();

getStyle (attribute)​

This method will return the style of the given element for the given attribute.

import static io.github.boykaframework.actions.elements.ElementActions.onElement;
. . .
String backgroundColor = onElement (locator).getStyle ("background-color");

tap​

This method will tap on element on the Mobile screen using W3C actions.

import static io.github.boykaframework.actions.elements.ElementActions.onElement;
. . .
onElement (locator).tap ();

getText​

This method is used to get the text of the given element.

import static io.github.boykaframework.actions.elements.ElementActions.onElement;
. . .
String text = onElement (locator).getText ();

verifyAttribute (attribute)​

This method is used to verify the given attribute of the given element.

import static io.github.boykaframework.actions.elements.ElementActions.onElement;
. . .
onElement (locator).verifyAttribute ("attribute-name").isEqualTo ("Swag Labs");

verifyIsDisplayed​

This method is used to verify the given element is displayed.

import static io.github.boykaframework.actions.elements.ElementActions.onElement;
. . .
onElement (locator).verifyIsDisplayed ().isTrue();

verifyIsEnabled​

This method is used to verify the given element is enabled.

import static io.github.boykaframework.actions.elements.ElementActions.onElement;
. . .
onElement (locator).verifyIsEnabled ().isTrue();

verifyIsSelected​

This method is used to verify the given element is selected.

import static io.github.boykaframework.actions.elements.ElementActions.onElement;
. . .
onElement (locator).verifyIsSelected ().isTrue();

verifyStyle (attribute)​

This method is used to verify the style of the given element locator.

import static io.github.boykaframework.actions.elements.ElementActions.onElement;
. . .
onElement (locator).verifyStyleOf ("color").isEqualTo ("Red");

verifyText​

This method is used to verify the text of the given element.

import static io.github.boykaframework.actions.elements.ElementActions.onElement;
. . .
onElement (locator).verifyText ().isEqualTo ("Swag Labs");