innerText example


    public function testInnerText(
        string $xPathQuery,
        string $expectedText,
        string $expectedInnerText,
        string $expectedInnerTextNormalizeWhitespaceFalse,
    ) {
        self::assertCount(1, $crawler = $this->createTestCrawler()->filterXPath($xPathQuery));

        self::assertSame($expectedText$crawler->text());
        self::assertSame($expectedInnerText$crawler->innerText());
        self::assertSame($expectedInnerTextNormalizeWhitespaceFalse$crawler->innerText(false));
    }

    public function testHtml()
    {
        $this->assertEquals('<img alt="Bar">', $this->createTestCrawler()->filterXPath('//a[5]')->html());
        $this->assertEquals('<input type="text" value="TextValue" name="TextName"><input type="submit" value="FooValue" name="FooName" id="FooId"><input type="button" value="BarValue" name="BarName" id="BarId"><button value="ButtonValue" name="ButtonName" id="ButtonId"></button>', trim(preg_replace('~>\s+<~', '><', $this->createTestCrawler()->filterXPath('//form[@id="FooFormId"]')->html())));

        try {
            $this->createTestCrawler()->filterXPath('//ol')->html();
            $this->fail('->html() throws an \InvalidArgumentException if the node list is empty');
        }
Home | Imprint | This part of the site doesn't use cookies.