Let's take a look at an example to see what it looks like to use these actions. For this example we will use a very simple example page where we can click on buttons to add and remove elements from the page. If you have not yet setup a project, you can follow the documentation on creating a web test to see how to get started. For this example the URL used in the test will be http://the-internet.herokuapp.com/add_remove_elements/.
Set Step Type to Action
addElement()method, so we can type that into the code input parameter for this addon. The
addElement()method does not have any arguments, so we can leave that field blank.
Execute addElement method
With that we can click on Create to create the test step and then run the test to see what happens.
When we do that, you can see that it has added a new button to the page
Delete Button Added
To freeze an element we just hover over it and hit shift twice quickly. We can then go to the Attributes option and see what attributes this element has.
document.getElementsByClassName()method. Since this method returns a list, we need to index it to get the first element and then call the
We can put that code directly into the step in TestProject
If we then run this step, the Delete Button will be hidden.
First of all, we will add another test step and leave the Type as Element Action. We then need to select the element, but since it is not visible on the page we will need to find it in another way. We can do this with the Element Explorer
If we then drill down into the on page elements we can find the hidden Delete button
Hidden Delete Button
Clicking on this will bring up the menu options for this element and we can then copy the xpath to use in our test step. We can then close the element explorer and return to the Create Step panel and click on select element. We can then use the plus at the bottom of that panel to add a new element.
Add a New Element
We can name the element, set the type to Button and use the XPATH locator. We can then paste in the xpath that we copied and add the element to our project.
Create New DeleteButton Element
At this point we can run this step and the button gets 'clicked' even though it is hidden. This can be verified by checking in the Element Explorer, where the Delete Button element will no longer be available.