Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chaining find_by_* seems to have no effect for xpath #1325

Open
mateusz-lachowski-codilime opened this issue Feb 5, 2025 · 0 comments
Open

Comments

@mateusz-lachowski-codilime

Problem:

I want to find a <td> from table, from given panel by using xpath and chaining find_by_* methods.

<div id="main">
<div class="panel">
<div class="heading">Table A</div>
<table>
<tr><td>Row 1</td><td>Value 1</td></tr>
</table>
</div>
<div class="panel">
<div class="heading">Table B</div>
<table>
<tr><td>Row 1</td><td>Value 1</td></tr>
</table>
</div></div>

panel = browser.find_by_xpath('//*[@id="main"]//div[@class="heading"][contains(normalize-space(), "Table A")]/following-sibling::table')
panel.find_by_tag("td") # return two elements from Table A
panel.find_by_xpath('//td') # will return all of td's

The reason why I'm using the xpath is that I want to find a cell with value next to some "label cell": //td[text()="Row 1"]/following-sibling::td[1] and in my code I have many of such row's with same names.

Expected behavior: it will return only td's from given panel.

Xpaths were tested also on http://xpather.com/ and it's working like expected.

Splinter version: 0.21.0, selenium: selenium/standalone-firefox:4.27

Browser setup like this:

browser = Browser(
            "remote",
            command_executor=SELENIUM_URL,
        )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant