You are here

public function PageContentTrait::getText in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/jcalderonzumba/mink-phantomjs-driver/src/PageContentTrait.php \Zumba\Mink\Driver\PageContentTrait::getText()

Given xpath, will try to get ALL the text, visible and not visible from such xpath

Parameters

string $xpath:

Return value

string

Throws

DriverException

File

vendor/jcalderonzumba/mink-phantomjs-driver/src/PageContentTrait.php, line 26

Class

PageContentTrait
Class PageContentTrait @package Zumba\Mink\Driver

Namespace

Zumba\Mink\Driver

Code

public function getText($xpath) {
  $elements = $this
    ->findElement($xpath, 1);

  //allText works only with ONE element so it will be the first one and also returns new lines that we will remove
  $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;
}