diff --git a/packages/testing/src/Support/HtmlTesting/TestableHtmlDocument.php b/packages/testing/src/Support/HtmlTesting/TestableHtmlDocument.php
index ff4ea3bfdf3..463357807ba 100644
--- a/packages/testing/src/Support/HtmlTesting/TestableHtmlDocument.php
+++ b/packages/testing/src/Support/HtmlTesting/TestableHtmlDocument.php
@@ -6,6 +6,7 @@
use DOMElement;
use DOMDocument;
+use DOMXPath;
use InvalidArgumentException;
use Illuminate\Support\Collection;
use Illuminate\Testing\Assert as PHPUnit;
@@ -80,12 +81,11 @@ public function getElementUsingQuery(string $selector): TestableHtmlElement
*/
public function getElementsByClass(string $class): Collection
{
- $xpath = new \DOMXPath($this->document); // Use the existing DOMDocument
+ $xpath = new DOMXPath($this->document);
$nodeList = $xpath->query("//*[contains(concat(' ', normalize-space(@class), ' '), ' $class ')]");
$collection = collect();
foreach ($nodeList as $node) {
- // Ensure we are only adding DOMElement objects to the collection.
if ($node instanceof DOMElement) {
$collection->push($this->parseNodeRecursive($node));
}