You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into what I consider a 'bizarre' issue the other day:
When a Symfony\Component\Panther\Client instance is used within the same calling function/method and the Symfony\Component\Panther\DomCrawler\Crawler instance is retrieved, everything works.
However, if the Crawler is retrieved from another function/method, Crawler::html() provides an empty string.
It's probably because in the second test, the destructor of Client is called. Maybe should we store a reference to the client in the crawler to prevent this bug.
My use case was a method that would accept a URL argument and could return a Crawler instance regardless of how Crawler was created (via BrowserKit, Panther, or populated via a Symfony\Component\HttpClient\HttpClient response.
I ultimately decided to discard the 3rd (HttpClient) option, and return a Symfony\Component\BrowserKit\AbstractBrowser instance instead from the method, as the Client is sometimes needed anyway.
I don't know if the Crawler should know about the Client or not - I just know I spent more time than I preferred to tracking down where things went wrong in this instance. Perhaps at least the Client destructor could populate a Crawler flag that would cause an Exception to be thrown if the Client was no longer available with an explanation?
Either way, thank you for your response and the great library.
I ran into what I consider a 'bizarre' issue the other day:
When a
Symfony\Component\Panther\Client
instance is used within the same calling function/method and theSymfony\Component\Panther\DomCrawler\Crawler
instance is retrieved, everything works.However, if the Crawler is retrieved from another function/method,
Crawler::html()
provides an empty string.Example class:
The
PantherTest::test1
method works as expected:but the
PantherTest::test2
method does not, even though the exact same code is duplicated inside another method:I've tried this on both my local dev server, and a remote debian/apache server with the same results.
The text was updated successfully, but these errors were encountered: