Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Dom crawler context bug #10260

Copy link
Copy link
Closed
Closed
Copy link
@Ragazzo

Description

@Ragazzo
Issue body actions

Currently crawler code is broken and filterXpath
does not take into account context in which it is executed in. Small code to reproduce issue:

<?php

require(__DIR__ . '/vendor/autoload.php');


$html = <<<HTML
<!DOCTYPE html>
<html lang="en">
<body>
    <a href="/index.php?r=site/login">Login</a>
    <form id="login-form" action="/index.php?r=site/login" method="post">
        <button type="submit">Submit</button>
    </form>
</body>
</html>
HTML;


$crawler = new Symfony\Component\DomCrawler\Crawler($html);


$newCrawler = $crawler->filterXPath("descendant-or-self::*[@id = 'login-form']");
var_dump($newCrawler->html()); 
//outputs form

var_dump($newCrawler->selectLink('Login')->html()); 
//outputs "Login", but there is no such link in form. It is only global

Code was broken by this commit. I checked out to commit before it and it works fine with giving me exception node list is empty.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.