public function getElementByText(string $text, string $selector, string $textSelector = null, TraversableElement $baseElement = null): ?NodeElement
    {
        $baseElement = $baseElement ?? $this->getSession()->getPage();

        $elements = $this->findAllElements($selector, $baseElement);
        foreach ($elements as $element) {
            if ($textSelector !== null) {
                try {
                    $elementText = $this->findElement($textSelector, 10, $element)->getText();
                } catch (\Exception $e) {
                    continue;
                }
            } else {
                $elementText = $element->getText();
            }
            if ($elementText === $text) {
                return $element;
            }
        }

        return null;
    }