Skip to content

Commit

Permalink
Merge pull request #399 from aik099/empty-getText-fix
Browse files Browse the repository at this point in the history
Fixing "getText" method returning an empty value on a visible element
  • Loading branch information
aik099 authored Nov 1, 2024
2 parents 6f4e09d + 3fc6c5d commit 6a2142e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Selenium2Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -638,11 +638,11 @@ public function getTagName(string $xpath)

public function getText(string $xpath)
{
$node = $this->findElement($xpath);
$text = $node->text();
$text = (string) str_replace(array("\r", "\r\n", "\n"), ' ', $text);

return $text;
return (string) str_replace(
array("\r", "\r\n", "\n"),
' ',
$this->executeJsOnXpath($xpath, 'return {{ELEMENT}}.innerText;')
);
}

public function getHtml(string $xpath)
Expand Down

0 comments on commit 6a2142e

Please sign in to comment.