Skip to content

nth-child selector seems not working properly #1018

Open
@timnew

Description

@timnew

I found nth-child selector is not working as expected.

Having a simple html

<div id="content">
    <table>
        <tbody>
        <tr>
            <td>1,1</td>
            <td>1,2</td>
        </tr>
        <tr>
            <td>2,1</td>
            <td>2,2</td>
        </tr>
        </tbody>
    </table>
</div>

And running tests as below

// Passed
expect(document.querySelector('#content > table > tbody > tr:nth-child(1) > td:nth-child(1)').text, equals('1,1')); 

// NoSuchMethodError: The getter 'text' was called on null.
expect(document.querySelector('#content > table > tbody > tr:nth-child(1) > td:nth-child(2)').text, equals('1,2')); 

// NoSuchMethodError: The getter 'text' was called on null.
expect(document.querySelector('#content > table > tbody > tr:nth-child(2) > td:nth-child(1)').text, equals('2,1')); 

// NoSuchMethodError: The getter 'text' was called on null.
expect(document.querySelector('#content > table > tbody > tr:nth-child(2) > td:nth-child(2)').text, equals('2,2'));

nth-child yields null

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