protected function quoteXpathAttribute(string $input): string
    {
        if (mb_strpos($input, '\'') === false) { // Selector does not contain single quotes
            return "'$input'"; // Encapsulate with double quotes
        }

        if (mb_strpos($input, '"') === false) { // Selector contain single quotes but not double quotes
            return "\"$input\""; // Encapsulate with single quotes
        }

        // When both single and double quotes are contained, escape each part individually and concat() all parts
        return "concat('" . strtr($input, ['\'' => '\', "\'", \'']) . "')";
    }