question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem with Get Element, cascaded selectors and/or *-prefix in Browser version 10+

See original GitHub issue

Describe the bug Prior to Browser library version 10, I used Get Element and the * character to capture the parent element containing given text (Practically identically like explained under the Cascaded selector syntax in the keyword documentation). I would later on pass that element around and use it as a selector to extract and assert information. This interaction worked in version 9.0.2, but in later versions it seems that Get Element doesn’t resolve to the element anymore, resulting in the future use of the retrieved variable not working as previously intended.

To Reproduce I’ve managed to reproduce the behaviour with the following page and test case. Pardon the simplicity.

page.html

<ul>
    <li>
        <button>
            <h3>namegoeshere</h3>
            <p>42</p>
            <p>24</p>
        </button>
    </li>
    <li>
        <button>
            <h3>anothernamegoeshere</h3>
            <p>foo</p>
            <p>bar</p>
        </button>
    </li>
</ul>

test.robot

*** Settings ***
Library   Browser

*** Test Cases ***
Get Element problem test
    New Page       ${EXECDIR}\\page.html
    # note the * -character. Again, see the Cascaded selector syntax in the keyword documentation as well.
    ${button_element}=    Get Element    *xpath=//button >> text="namegoeshere"
    ${val}=    Get Text    ${button_element} >> xpath=//p[1]
    should be equal    ${val}    42

Expected behavior the ${button_element} variable should get resolved to the first button element in the example page, containing the h3 element with the text namegoeshere and the p elements. Then that variable should be used as selector in the next line, retrieving the text 42 in the p element. The following should be equal assertion in the test case should then succeed. I’ve confirmed this to work with Browser library version 9.0.2.

However in Browser library version 10+ (in this case 10.1.0) the Get Text fails on a TimeoutError.

TimeoutError: locator.elementHandle: Timeout 10000ms exceeded.
=========================== logs ===========================
waiting for selector "*xpath=//button >> text="namegoeshere" >> xpath=//p[1]"
============================================================

This issue is present in all 3 browser engines, regardless of headless mode. Python version 3.10, Node version 14.18.1.

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser confirmed on all browser engines
  • Version 21H1

Additional context Was the desired behavior I’ve described even intended in the first place🤔

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Kahiiscommented, Feb 5, 2022

Thanks a ton @aaltat for doing the research and getting back to this issue! Let’s hope a fix is coming to the playwright side of things in the future.

1reaction
aaltatcommented, Dec 20, 2021

I might have an idea what causes this, but I need to do some experiments with Playwright.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Advanced element selector with element prefix does not work ...
I am having problems with an advanced negation pseudo-class selector in a :not(s) selector (!!in Google Chrome!!). I have this HTML markup:
Read more >
Untitled
Rockriver lefty, Pre rinsing quinoa, Get back demi lovato 2014, Dafiti verao, Us house senate members, Black key piano notes chart, Giumarello's happy...
Read more >
Untitled
Zamenhofa 20 olsztyn, Mateso na damu sehemu ya 10, Ondu, Efterskolen kastanievej, York city council recycling, Lipsy floral skater dress, Quadrant 4 media, ......
Read more >
Untitled
Grognet flying service, Cercei nou nascuti tortite, Hertz hl 70 volumen, Universidad untdf, Mazha malayalam songs download, Ie10 updatepanel not working, ...
Read more >
Cisco IOS Interface and Hardware Component Command ...
For example, if you have a 48-port 10/100BASE-T Ethernet module that is installed in a 13-slot chassis, valid values for the slot number...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found