Q:

How to use count() function in xpath of selenium?

Using findElements() and size() methods we can get the count.
But I want to extract the count using count() function in the xpath.
Will the count function return an integer value?
Suppose,
My xpath is (//input[@id='stack'])[3] and there are 3 matching nodes with //input[@name='hai']
Can I modify my xpath like below?
(//input[@id='stack'])[count(//input[@name=''hai])]

A:

Yes, if
count(//input[@name='hai'])

evaluates to 
3

then
(//input[@id='stack'])[count(//input[@name='hai'])]

will select the same nodes as 
(//input[@id='stack'])[3]

would select.
However, your intent is quite unclear, especially given that

//input[@id='stack'] will select all of the input elements with
an id attribute value of 'stack'.  Usually id attribute values
are unique across the document, so usually this would select only a
single element.
(//input[@id='stack'])[count(//input[@name='hai'])] assumes that there are at least as many input elements id'ed as 'stack' as there are input elements named 'hai' -- an odd assumption.

