Page 1 of 1

Question about XPath related to DOM element

PostPosted: Wed Apr 27, 2016 3:16 pm
by JerMaren
Afternoon.

Hey guys, does eValid's command capability provide for either use of an explicitly XPath or the use of regular expressions in finding a DOM element?

Thanks a bunch.

Re: Question about XPath related to DOM element

PostPosted: Thu Apr 28, 2016 8:34 am
by eValid
JerMaren wrote:Afternoon.

Hey guys, does eValid's command capability provide for either use of an explicitly XPath or the use of regular expressions in finding a DOM element?

Thanks a bunch.


Thanks for asking JerMaren.

XPath is a way of identifying a path in the DOM hierarchy, and it has some string processing functions that work very similarly to how a Regular Expression (RE) works.

An XPath expression is effectively an address into the DOM, but it can be quite general, implying a search sequence that finds something based on a string match.

An RE is specifically a search pattern for use in scanning a document that describes matches that occur in the document.

You can't quite put a RE in an XPath, but you can get pretty close to it using the string processing methods that are built in to the XPath capability.

The most common way an XPath is used in web application testing is to specify the path to a DOM element that has a string match within the string of some DOM node that has a bunch of properties defined on it.

You write the XPath and include it in your JavaScript and the browser takes care of filling in the blanks.

You can find a particular element knowing only a few details of its expected content.

The DOM API that's used is the "GetElementBy..." method group.

These to Wikipedia articles are actually quite good:

https://en.wikipedia.org/wiki/XPath

https://en.wikipedia.org/wiki/Regular_expression

What eValid does is combine these two ideas in the IndexFindElementEx command, described here:

http://www.e-valid.com/Products/Documen ... nt.ex.html

This command accepts an RE (which also could be a simple string) as an argument and uses matches made at the RE level to identify the first matching DOM element, the value of which it stores into the current sourceIndex value.

-- eValid Support