Automation Tests Basic Concepts
Automation Tests Basic Concepts
Page Factory
The PageFactory pa ern is used, along with the Page Object
pa ern when implemen ng func onal tests to make the code
more maintainable and avoid wri ng code like:
De este modo, para hacer referencia a un elemento web, bastaría con importar:
•
•
•
•
•
tt
ti
ti
ti
tt
ti
ti
ti
ti
U lizar FindBy para tomar los elementos, así;
Inicializar esos elementos de la clase (u objeto de Page Object) con el PageFactory: (hay
que pasar el driver y la propia clase)
The bene t is that if the UI changes for the page, the tests
themselves don't need to be changed, only the code inside the page
object needs to change, subsequently all the changes to support
that new UI are there. In one single place.
TDD
These acceptance tests represent the user's point of view and act as
a form of requirements to describe how the system will work, in
addi on to serving as a way to verify that the system works as
intended. ATDD is closer to a process rather than an ac vity.
It gives you the ability to remove logical details from the tests.
This type of scenario provides more details to the reader about the
steps to take to achieve a result, and is easier to automate because
the step does a single ac on, but creates very long scenarios, and is
sensi ve to changes in the interface, which is not desirable. This
type of scenario can be used where details are required to clearly
communicate how a feature works.
Example:
And click on the "I accept the terms of the contract" eld
ti
ti
ti
fi
ti
fi
ti
Then you receive an email con rming your new Declara ve mode of
registra on
Declara ve Gherkin
Cucumber
These func onal descrip ons are wri en in Gherkin language which
is a domain-speci c language and readable by the business area.
FIRST is the acronym for the ve characteris cs that our unit tests
must have to be considered quality tests:
Fast (fast)
Independent (independent)
Repeatable (repeatable)
The result of the tests must be the same regardless of the server on
which it runs. Tests should not have server dependencies, user
con gura on or execu on me.
Self-valida ng (self-evaluable)
fi
tt
ti
ti
ti
ti
fi
tt
ti
One of the points in favor of automated tests is that we can execute
them simply by pressing a bu on or even make them run
automa cally a er another process.
Timely (opportune)
INVEST Principle
Nego able (Nego able): avoid including too much detail, so that
user stories are exible and can be modi ed.
ti
ti
tt
ft
fl
ti
tt
ti
fi
fi
ti
Valuable: user stories must provide some value to the end user.
Scalable: make user stories simple, so that they can be ordered and
priori zed.
Smart Method
When we break down our user stories into tasks, we will use the
SMART method, a method that helps us evaluate whether our tasks
are correctly de ned.
"Make interfaces that are speci c to a type of customer," that is, for
a speci c purpose.
Abstrac ons should not depend on the details. The details should
depend on the abstrac ons.
Arrange: It is the part of the Unitary Test where all the code is
con gured to run the unitary test, we declare the variables and
create the instance of the objects of the classes.
Act (Law): This is the phase of the Unit Test where the code to be
tested is executed, where the method we are tes ng (verifying) is
called. In this sec on, it is where the input parameters are passed
to the method and where the result returned by the method is
collected.
Assert (A rm): In this part compare the actual result of the call
with the expected result. The test is passed or not depends on this
part of the statement. Usually, the Assert class is used for this
opera on.
fi
ti
tt
ffi
ti
ti
ti
Taken from: h p://joaquin.medina.name/web2008/documentos/
informa ca/documentacion/visualEstudio/PruebasUnitarias/
2017_04_19_PruebasUnitarias_EstructuraDeCodigo.html
Class
Objects
Abstrac on:
Encapsula on:
Polymorphism:
Inheritance:
Members of data, class or methods that are not declared using any
access modi er, that is, that have a default access modi er, are only
accessible within the same package.
fi
fi
fi
fi
fi
fi
Private
h ps://www.federico-toledo.com/en-que-nivel-conviene-automa zar/
tt
fi
fi
ti
Xpath
It is a syntax or language to nd any element on the web page using the XML path expression and
the HTML DOM structure.
Localizador Descripción
ID Este es el primer localizador que debemos tratar de u lizar pues la mayoría de las
veces iden can de forma única al elemento.
Name Este localizador es el segundo que debemos tratar de u lizar en caso de que no
tengamos un id. Usualmente los nombres de los elementos son únicos y nos
permiten ubicar un elemento con facilidad.
Class Nombre de la clase de elemento.
TagName Este localizador busca por el nombre del tag del elemento dentro del
DOM(Document Object Model)
LinkText Este localizador busca links en la página donde el texto coincida con el parámetro
que le pasamos al método linkText ().
CssSelector Este localizador, es en sí una estrategia de localización que u liza el lenguaje CSS
(Cascade Style Sheet) para elementos que no enen ID, nombre o clase.
Xpath Se requiere XPath para encontrar el elemento dinámico y atravesar entre varios
elementos de la página web
ti
fi
ti
fi
ti
ti
ti
ti
ti
ti
Tipos de Xpath
1. Xpath absoluto
Ejemplo:
Para Xpath rela vo, la ruta comienza desde el medio de la estructura HTML
DOM. Comienza con la barra diagonal doble (//), lo que signi ca que puede buscar el
elemento en cualquier lugar de la página web.
Puede comenzar desde la mitad de la estructura HTML DOM y no es necesario escribir
xpath largo.
Ejemplo
ti
ti
ti
fi
fi
Tomado de: h ps://www.guru99.com/xpath-selenium.html
tt