DataSift\Storyplayer\BrowserLib\DomElementSearch::getElementsByXpath PHP Method

getElementsByXpath() public method

public getElementsByXpath ( array $xpathList ) : array<\DataSift\WebDriver\WebDriverElement>
$xpathList array
return array<\DataSift\WebDriver\WebDriverElement>
    public function getElementsByXpath($xpathList)
    {
        // shorthand
        $topElement = $this->getTopElement();
        // what are we doing?
        $log = usingLog()->startAction("search the browser's DOM using a list of XPath queries");
        // our set of elements to return
        $return = array();
        try {
            foreach ($xpathList as $xpath) {
                $elements = $log->addStep("find elements using xpath '{$xpath}'", function () use($topElement, $xpath) {
                    return $topElement->getElements('xpath', $xpath);
                });
                if (count($elements) > 0) {
                    // add these elements to the total list
                    $return = array_merge($return, $elements);
                }
            }
        } catch (Exception $e) {
            // log the result
            $log->endAction("no matching elements");
            // report the failure
            throw new E5xx_ActionFailed(__METHOD__);
        }
        // if we get here, we found a match
        $log->endAction("found " . count($return) . " element(s)");
        return $return;
    }