Package com.shaft.cucumber
Class ElementSteps
java.lang.Object
com.shaft.cucumber.ElementSteps
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidClicks on a certain element using Selenium WebDriver, or JavaScript.voidclickAndHold(String locatorType, String locatorValue) Waits for the element to be clickable, and then clicks and holds it.voidclipboardActions(String action, String locatorType, String locatorValue) Attempts to perform a native clipboard action on the text from a certain web element, like copy/cut/pastevoiddoubleClick(String locatorType, String locatorValue) Double-clicks on an element using Selenium WebDriver's Actions LibraryvoiddragAndDrop(String sourceLocatorType, String sourceLocatorValue, String destinationLocatorType, String destinationLocatorValue) Drags the source element and drops it onto the destination elementvoiddragAndDropByOffset(String locatorType, String locatorValue, int xOffset, int yOffset) Drags the source element and drops it onto the determined offsetvoidHovers over target element.voidPresses a specific keyboard key into the target element.voidSelects an element from a dropdown list using its displayed textvoidsetValueUsingJavaScript(String value, String locatorType, String locatorValue) Used to SetProperty value for an element (hidden or visible) using javascriptvoidsubmitFormUsingJavaScript(String locatorType, String locatorValue) Used to submit a form using javascriptvoidChecks if there is any text in an element, clears it, then types the required string into the target element.voidtypeAppend(String text, String locatorType, String locatorValue) Appends the required string into the target element, regardless of the current text value.voidtypeFileLocationForUpload(String absoluteFilePath, String locatorType, String locatorValue) ValidationEnums the required file path into an input[type='file'] button, to successfully upload the target file.voidtypeSecure(String text, String locatorType, String locatorValue) Checks if there is any text in an element, clears it, then types the required string into the target element.
-
Constructor Details
-
ElementSteps
-
-
Method Details
-
type
@When("I Type {string} into the element found by {string}: {string}") public void type(String text, String locatorType, String locatorValue) Checks if there is any text in an element, clears it, then types the required string into the target element.- Parameters:
text- the target text that needs to be typed into the target webElementlocatorType- can be {id, tagname, classname, name, linktext, partiallinktext, cssselector, xpath}locatorValue- the value/expression of the desired element locator
-
keyPress
@When("I Press {string} into the element found by {string}: {string}") public void keyPress(String key, String locatorType, String locatorValue) Presses a specific keyboard key into the target element.- Parameters:
key- the target key that needs to be pressed into the target webElement. Supported keys are defined in the org.openqa.selenium.Keys enumlocatorType- can be {id, tagname, classname, name, linktext, partiallinktext, cssselector, xpath}locatorValue- the value/expression of the desired element locator
-
typeSecure
@When("I Type {string} securely into the element found by {string}: {string}") public void typeSecure(String text, String locatorType, String locatorValue) Checks if there is any text in an element, clears it, then types the required string into the target element. Obfuscates the written text in the output report. This action should be used for writing passwords and secure text.- Parameters:
text- the target text that needs to be typed into the target webElementlocatorType- can be {id, tagname, classname, name, linktext, partiallinktext, cssselector, xpath}locatorValue- the value/expression of the desired element locator
-
typeAppend
@When("I Append the text {string} to the element found by {string}: {string}") public void typeAppend(String text, String locatorType, String locatorValue) Appends the required string into the target element, regardless of the current text value.- Parameters:
text- the target text that needs to be appended into the target webElementlocatorType- can be {id, tagname, classname, name, linktext, partiallinktext, cssselector, xpath}locatorValue- the value/expression of the desired element locator
-
typeFileLocationForUpload
@When("I Upload the file {string} to the element found by {string}: {string}") public void typeFileLocationForUpload(String absoluteFilePath, String locatorType, String locatorValue) ValidationEnums the required file path into an input[type='file'] button, to successfully upload the target file.- Parameters:
absoluteFilePath- the full path to the file that needs to be uploadedlocatorType- can be {id, tagname, classname, name, linktext, partiallinktext, cssselector, xpath}locatorValue- the value/expression of the desired element locator
-
click
@When("I Click the element found by {string}: {string}") public void click(String locatorType, String locatorValue) Clicks on a certain element using Selenium WebDriver, or JavaScript.- Parameters:
locatorType- can be {id, tagname, classname, name, linktext, partiallinktext, cssselector, xpath}locatorValue- the value/expression of the desired element locator
-
clickAndHold
@When("I Click and hold the element found by {string}: {string}") public void clickAndHold(String locatorType, String locatorValue) Waits for the element to be clickable, and then clicks and holds it.- Parameters:
locatorType- can be {id, tagname, classname, name, linktext, partiallinktext, cssselector, xpath}locatorValue- the value/expression of the desired element locator
-
clipboardActions
@When("I use the clipboard to perform {string} on the element found by {string}: {string}") public void clipboardActions(String action, String locatorType, String locatorValue) Attempts to perform a native clipboard action on the text from a certain web element, like copy/cut/paste- Parameters:
action- supports the following actions "copy", "paste", "cut", "select all", "unselect"locatorType- can be {id, tagname, classname, name, linktext, partiallinktext, cssselector, xpath}locatorValue- the value/expression of the desired element locator
-
doubleClick
@When("I Double-click the element found by {string}: {string}") public void doubleClick(String locatorType, String locatorValue) Double-clicks on an element using Selenium WebDriver's Actions Library- Parameters:
locatorType- can be {id, tagname, classname, name, linktext, partiallinktext, cssselector, xpath}locatorValue- the value/expression of the desired element locator
-
dragAndDrop
@When("I Drag the element found by {string}: {string} and drop it on the element found by {string}: {string}") public void dragAndDrop(String sourceLocatorType, String sourceLocatorValue, String destinationLocatorType, String destinationLocatorValue) Drags the source element and drops it onto the destination element- Parameters:
sourceLocatorType- can be {id, tagname, classname, name, linktext, partiallinktext, cssselector, xpath}sourceLocatorValue- the value/expression of the source element locator that's draggabledestinationLocatorType- can be {id, tagname, classname, name, linktext, partiallinktext, cssselector, xpath}destinationLocatorValue- the value/expression of the target element locator that's droppable
-
dragAndDropByOffset
@When("I Drag the element found by {string}: {string} and drop it by offset x={int} and y={int}") public void dragAndDropByOffset(String locatorType, String locatorValue, int xOffset, int yOffset) Drags the source element and drops it onto the determined offset- Parameters:
locatorType- can be {id, tagname, classname, name, linktext, partiallinktext, cssselector, xpath}locatorValue- the value/expression of the desired element locatorxOffset- the horizontal offset by which the element should be movedyOffset- the vertical offset by which the element should be moved
-
hover
@When("I Hover over the element found by {string}: {string}") public void hover(String locatorType, String locatorValue) Hovers over target element.- Parameters:
locatorType- can be {id, tagname, classname, name, linktext, partiallinktext, cssselector, xpath}locatorValue- the value/expression of the desired element locator
-
select
@When("I Select {string} from the drop-down list element found by {string}: {string}") public void select(String text, String locatorType, String locatorValue) Selects an element from a dropdown list using its displayed text- Parameters:
text- the text of the choice that you need to select from the target dropDown menulocatorType- can be {id, tagname, classname, name, linktext, partiallinktext, cssselector, xpath}locatorValue- the value/expression of the desired element locator
-
setValueUsingJavaScript
@When("I Set the value {string} into the element found by {string}: {string}") public void setValueUsingJavaScript(String value, String locatorType, String locatorValue) Used to SetProperty value for an element (hidden or visible) using javascript- Parameters:
value- the desired value that should be SetProperty for the target elementlocatorType- can be {id, tagname, classname, name, linktext, partiallinktext, cssselector, xpath}locatorValue- the value/expression of the desired element locator
-
submitFormUsingJavaScript
@When("I Submit the form found by {string}: {string}") public void submitFormUsingJavaScript(String locatorType, String locatorValue) Used to submit a form using javascript- Parameters:
locatorType- can be {id, tagname, classname, name, linktext, partiallinktext, cssselector, xpath}locatorValue- the value/expression of the desired element locator
-