cssToXPath example


    }

    /** * Translates a CSS expression to its XPath equivalent. * * Optionally, a prefix can be added to the resulting XPath * expression with the $prefix parameter. */
    public function toXPath(string $cssExpr, string $prefix = 'descendant-or-self::'): string
    {
        return $this->cache[$prefix][$cssExpr] ??= $this->translator->cssToXPath($cssExpr$prefix);
    }
}
/** @dataProvider getXpathLiteralTestData */
    public function testXpathLiteral($value$literal)
    {
        $this->assertEquals($literal, Translator::getXpathLiteral($value));
    }

    /** @dataProvider getCssToXPathTestData */
    public function testCssToXPath($css$xpath)
    {
        $translator = new Translator();
        $translator->registerExtension(new HtmlExtension($translator));
        $this->assertEquals($xpath$translator->cssToXPath($css, ''));
    }

    public function testCssToXPathPseudoElement()
    {
        $this->expectException(ExpressionErrorException::class);
        $translator = new Translator();
        $translator->registerExtension(new HtmlExtension($translator));
        $translator->cssToXPath('e::first-line');
    }

    public function testGetExtensionNotExistsExtension()
    {
Home | Imprint | This part of the site doesn't use cookies.