PageContentTrait.php in Zircon Profile 8.0
File
vendor/jcalderonzumba/mink-phantomjs-driver/src/PageContentTrait.php
View source
<?php
namespace Zumba\Mink\Driver;
use Behat\Mink\Exception\DriverException;
trait PageContentTrait {
public function getContent() {
return $this->browser
->getBody();
}
public function getText($xpath) {
$elements = $this
->findElement($xpath, 1);
$text = $this->browser
->allText($elements["page_id"], $elements["ids"][0]);
$text = trim(str_replace(array(
"\r",
"\r\n",
"\n",
), ' ', $text));
$text = preg_replace('/ {2,}/', ' ', $text);
return $text;
}
public function getHtml($xpath) {
$elements = $this
->findElement($xpath, 1);
return $this->browser
->allHtml($elements["page_id"], $elements["ids"][0], "inner");
}
public function getOuterHtml($xpath) {
$elements = $this
->findElement($xpath, 1);
return $this->browser
->allHtml($elements["page_id"], $elements["ids"][0], "outer");
}
public function getScreenshot() {
$options = array(
"full" => true,
"selector" => null,
);
$b64ScreenShot = $this->browser
->renderBase64("JPEG", $options);
if (($binaryScreenShot = base64_decode($b64ScreenShot, true)) === false) {
throw new DriverException("There was a problem while doing the screenshot of the current page");
}
return $binaryScreenShot;
}
}