public static function elementAt($element, $position)
    {
        if (is_int($position) && $position < 0) {
            $position++; // -1 points to the last element
            $position = 'last()-'.abs($position);
        }
        if ($position === 0) {
            throw new \InvalidArgumentException(
                '0 is not valid element position. XPath expects first element to have index 1'
            );
        }
        return sprintf('(%s)[position()=%s]', self::toXPath($element), $position);
    }
public static function elementAt($element, $position)
    {
        if (is_int($position) && $position < 0) {
            $position++; // -1 points to the last element
            $position = 'last()-'.abs($position);
        }
        if ($position === 0) {
            throw new \InvalidArgumentException(
                '0 is not valid element position. XPath expects first element to have index 1'
            );
        }
        return sprintf('(%s)[position()=%s]', self::toXPath($element), $position);
    }
public static function elementAt ( $ element , $ position ) { if ( is_int ( $ position ) && $ position < 0 ) { $ position ++ ; // -1 points to the last element $ position = 'last()-' . abs ( $ position ) ; } if ( $ position === 0 ) { throw new \ InvalidArgumentException ( '0 is not valid element position. XPath expects first element to have index 1' ) ; } return sprintf ( '(%s)[position()=%s]' , self :: toXPath ( $ element ) , $ position ) ; }
Locates element at position.
Either CSS or XPath locator can be passed as locator,
position is an integer. If a negative value is provided, counting starts from the last element.
First element has index 1

```php
<?php
use Codeception\Util\Locator;

Locator::elementAt('//table/tr', 2); // second row
Locator::elementAt('//table/tr', -1); // last row
Locator::elementAt('table#grind>tr', -2); // previous than last row
```

@param string $element CSS or XPath locator
@param int $position xpath index

@return mixed
Locates element at position . Either CSS or XPath locator can be passed as locator position is an integer . If a negative value is provided counting starts from the last element . First element has index 1