Skip to content

Commit

Permalink
Fixing "getText" method returning an empty value on a visible element
Browse files Browse the repository at this point in the history
  • Loading branch information
aik099 committed Nov 1, 2024
1 parent 6f4e09d commit 3fc6c5d
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 3fc6c5d

Please sign in to comment.