Test automation on web pages

Asked

Viewed 1,665 times

4

I would like the indication of tools to record the data entry on the page. I have already used the Selenium IDE, Selenium Web Driver. I saw that there is the iMacros. I am programming in JSF, Java and Primefaces.

My problem is this, I recorded through the Selenium IDE, but it is time that it loses the reference of the entries on the page. Then I have to redo the test from the wrong reference, so there are other tools to work to automate data entry?

iMacros didn’t like it very much because it’s not as simple and efficient to work with as the Selenium IDE.

3 answers

2

Here has a complete list of test automation tools.

Selenium is an excellent tool and I recommend trying to fix your problem by following a few steps as indicated Here. From what I saw you have to wait for the element to appear on the page and stay fixed before using it.

  • Face the page is fully loaded you understand, but the reference of some elements is wrong. I do not know why they change. And when you have a comboBox use the Tab it does not select, only through the click. I’ll read what you posted. Thank you

1

The problem you are facing can be divided into two points:

  • elements with dynamic Ids
  • some elements appear as an html element (like a combobox), but are actually a multi-element junction (instead of being one with multiple elements it usually has one with multiple s or
  • s).

Tell us what the html source code or even combo behavior looks like. There are types of location on Selenium that can help you interact with elements like this.

0

Once I created a web testing framework, which is actually a wrapper for Selenium, for a company that works with JSF.

The problem with JSF is exactly the one pointed out by Elias in the first item on the list: it generates dynamic Ids for many elements. This makes it impossible for Firefox’s Selenium IDE to always run the same way.

For example, if you do not set an ID for any page element, JSF will take care of it. A button on a form, for example, can end up as the id meuFormulario:j_id45674 (this can change from one run to another) and a field in a datatable tabela:0:nomeCampo (it doesn’t change, but it’s hard to work).

To get around these problems, the solution was to use CSS and Xpath selectors using the attribute name for form fields and other attributes for images.

Finally, the solution I found was to create such a framework that, among other things, provided some methods that encapsulated selectors for the company’s standard components.

For example, every inclusion record had a button with a specific class attribute, for example, botao-incluir. In other cases, the button contained a specific image. So I created a class that all test classes could extend or import statically and use more or less like this (in Java):

public class CadastroCliente extends TestBase {

    @Test
    public void cadastrarCliente() {
        type(campo("nome"));
        type(campo("idade"));
        click(botaoIncluir());
        aguardar();
    }

}

In JSF, the field nome, for example, could have the ID generated as formCad:panel10:nome. So the method campo() would actually return a selector like this:

css=input[id$=':nome']

The above selector is a CSS selector that searches for an element input on the page whose ID ends with :nome.

The methods type and click that are in the sample code are Wrappers of Selenium that I made specially adapted to the system in question.

The advantage of abstracting Selenium’s original methods is that there was often some specific behavior that required special treatment. In this case, I simply adjusted the Wrapper class without touching the tests.

The method aguardar(), for example, you can automatically do checks on validation errors, that is of course, if there is a pattern followed throughout the system.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.