Knowledge Base Article

Home Page > Knowledge Base > Rapise

Home Page > Knowledge Base > Rapise > Rapise Web

Article Different XPath Options in Rapise 4.0

by Adam S on Friday, February 26, 2016

When testing complex data-driven web applications using Rapise, it is helpful to understand the different ways that Rapise can automatically learn the objects. Rapise can learn an object using either XPATH or CSS. In the case of XPATH there are several strategies that Rapise can use to make the testing more robust. This article describes these strategies and provides some suggestions about which one is the best to use for different scenarios.

The WebSpy has variety of options for XPath generation. Having a number of different approaches for generating XPath has its benefits. It gives Rapise incredible flexibility in getting the best results for different situations:

1.Sometimes we can recognize an element by its text. In such cases the simplest and most efficient XPath will use the node text.

2.Sometimes we have a regular structure (tables and grids) and it is better to have row and column indices inside the XPath.

3.Sometimes we deal with an application framework that uses custom attributes (e.g. aria, angular, bootstrap). So if we use them in our XPath then it will be cleaner and more robust.




The Web Spy currently supports the following different types of XPath:

·xpath_full - generates a fully featured XPath path using elements without attributes. This XPath starts with /html and goes through body and other elements towards the required node.
 

·xpath_min - generated with the attributes defined in the 'DOM Attributes Include Filter'. If the include filter is empty, then it is produced with all attributes except those defined in the 'DOM Attributes Exclude Filter'. For example, if the include filter contains the 'widgetid' custom attribute then the generated XPath would be: //div[@widgetid="dojox_grid__View_1"]
 

·xpath_indexed - considers the node as nth of the same kind. For example, the page may contain 250 <a href=""> links across the page, and we want to learn the link somewhere in the middle. In this case indexed XPath will be of the form (//a)[123]
 

·xpath_std - generated and minimized with use of pre-selected set of attributes:

oalign

oclass

ostyle

osize

otabindex

ovalue

owidth

oheight

ocolspan

orowspan

ocellspacing

ocellpadding

oborder

oon* (i.e. onclick, onblur and so on)

oUsually it contains most common attributes: id, name, for, role.
 

·xpath_aria - generated with the use of just the core id/name attributes plus the special aria attributes:

oid

oname

ofor

orole

oaria-*

 ·xpath_text - if possible, generated to match an HTML node simply by its text. For example, <button>Refresh</button> is found by: //button[normalize-space(text())="Refresh"]. In many cases this value is empty. This means that there are more than one node with such text.

Attachments
Article Info
Last Updated: 2/26/2016
Article ID: KB192
# Views: 234
Powered by KronoDesk v1.1.0.15 | © Copyright Inflectra Corporation 2011-2016 | Licensed to Inflectra Corporation.