scrapinghub / portia

Visual scraping for Scrapy
BSD 3-Clause "New" or "Revised" License
9.3k stars 1.4k forks source link

Selector test fails on a simple html #695

Open eng1neer opened 7 years ago

eng1neer commented 7 years ago

I'm trying to modify Portia's selector generation logic to suit my needs and I stumbled upon a case where a following simple selector test doesn't work as intended (test fails):

test('Simple selector test', function(assert) {
    const $elements = Ember.$('<body><div id="div1"></div></body>');
    const selector = BaseSelectorGenerator.create({
        elements: $elements.find('#div1').toArray()
    });
    assert.equal(selector.get('selector'), '#div1');
});

It also does not work if I change the html to <div id="div1"></div>, but starts to work if I change it to <div><div id="div1"></div></div>.

Is there a reason for this behavior or is it a bug?