Chris@0: browser->getBody(); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Given xpath, will try to get ALL the text, visible and not visible from such xpath Chris@0: * @param string $xpath Chris@0: * @return string Chris@0: * @throws DriverException Chris@0: */ Chris@0: public function getText($xpath) { Chris@0: $elements = $this->findElement($xpath, 1); Chris@0: //allText works only with ONE element so it will be the first one and also returns new lines that we will remove Chris@0: $text = $this->browser->allText($elements["page_id"], $elements["ids"][0]); Chris@0: $text = trim(str_replace(array("\r", "\r\n", "\n"), ' ', $text)); Chris@0: $text = preg_replace('/ {2,}/', ' ', $text); Chris@0: return $text; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns the inner html of a given xpath Chris@0: * @param string $xpath Chris@0: * @return string Chris@0: * @throws DriverException Chris@0: */ Chris@0: public function getHtml($xpath) { Chris@0: $elements = $this->findElement($xpath, 1); Chris@0: //allText works only with ONE element so it will be the first one Chris@0: return $this->browser->allHtml($elements["page_id"], $elements["ids"][0], "inner"); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Gets the outer html of a given xpath Chris@0: * @param string $xpath Chris@0: * @return string Chris@0: * @throws DriverException Chris@0: */ Chris@0: public function getOuterHtml($xpath) { Chris@0: $elements = $this->findElement($xpath, 1); Chris@0: //allText works only with ONE element so it will be the first one Chris@0: return $this->browser->allHtml($elements["page_id"], $elements["ids"][0], "outer"); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns the binary representation of the current page we are in Chris@0: * @throws DriverException Chris@0: * @return string Chris@0: */ Chris@0: public function getScreenshot() { Chris@0: $options = array("full" => true, "selector" => null); Chris@0: $b64ScreenShot = $this->browser->renderBase64("JPEG", $options); Chris@0: if (($binaryScreenShot = base64_decode($b64ScreenShot, true)) === false) { Chris@0: throw new DriverException("There was a problem while doing the screenshot of the current page"); Chris@0: } Chris@0: return $binaryScreenShot; Chris@0: } Chris@0: }