-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getText() returns text other drivers does not #153
Comments
DomCrawler is simply using php's DOMNode: https://www.php.net/manual/en/class.domnode.php#domnode.props.textcontent |
@jonathanjfshaw yep and it's returning what |
I see no issue here. The Selenium driver is talking to a real browser and can ask to return only text visible to a user. The BrowserKit being a headless driver only looking at HTML tags and parsing them to its knowledge. This way stripping all HTML tags will leave their content in place resulting in the effect you're getting. @alexpott , I'm recommending to use the Code below (maybe not working) is how I'll be getting the contents of a document. $body_text = $session->getPage()->find('xpath', '//body')->getText(); |
@aik099 body can contain script tags. Adding script tags just before closing the body tag is often advocated for performance reasons. |
\Behat\Mink\Driver\BrowserKitDriver::getText() will return text in the head section and also any json on the page that's contained in a
script
tag in the HTML body. \Behat\Mink\Driver\Selenium2Driver::getText(), for example, will not return text from the head section or script tags in the body section. Given the Mink documentation states:I'm not sure if this is a Symfony\DomCrawler issue or not.
See for a discussion of the affects of this - https://www.drupal.org/project/drupal/issues/3175718
The text was updated successfully, but these errors were encountered: